Skip to content

Commit a479035

Browse files
authored
Fix the setting of variables for QueryAzureDevOpsExtensionVersion@3 (#341)
* Restore old `outputVariable` input, But this time with warning. * Adding old Extension.Version behavior back in with best level of compatibility. * Removing default value from outputVariable, This prevents the YAML helper from automatically adding it in. * Remove the outputVariable declaration from the task.json * Always set both local and output variables for `Extension.Version`
1 parent 723f8e9 commit a479035

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

BuildTasks/ExtensionVersion/v3/ExtensionVersion.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ function setVersion(version: string) {
99
if (tl.getBoolInput("setBuildNumber", false)) {
1010
tl.command("build.updatebuildnumber", null, version);
1111
}
12+
13+
const outputVariable = tl.getInput("outputVariable", false);
14+
if (outputVariable) {
15+
const setOutputFlag = tl.getBoolInput("setOutputFlag", false) || false;
16+
tl.warning("Using of deprecated 'outputVariable' parameter. Remove this parameter and add 'name: {{Stepname}}' to this step and reference '{{StepName}}.Extension.Version' in a future step instead.");
17+
tl.setVariable(outputVariable, version, false, setOutputFlag);
18+
}
1219

20+
console.log("Setting local variable 'Extension.Version'.");
21+
tl.setVariable("Extension.Version", version, false, false);
22+
console.log("Setting output variable '{{StepName}}.Extension.Version'.");
1323
tl.setVariable("Extension.Version", version, false, true);
1424
}
1525

BuildTasks/ExtensionVersion/v3/task.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,24 @@
122122
"helpMarkDown": "Updates the Build Number with the new version number.",
123123
"groupName": "version"
124124
},
125+
{
126+
"name": "outputVariable",
127+
"type": "string",
128+
"label": "Output Variable (deprecated)",
129+
"defaultValue": "",
130+
"required": false,
131+
"helpMarkDown": "The variable name to assign the version to. Specify only the name, e.g.: `ExtensionVersion`, not `$(ExtensionVersion)`.",
132+
"groupName": "backcompat"
133+
},
134+
{
135+
"name": "setOutputFlag",
136+
"type": "boolean",
137+
"label": "Set Output flag on Output Variable (deprecated)",
138+
"defaultValue": false,
139+
"required": false,
140+
"helpMarkDown": "When this is set to true the task will set the Output flag on the provided outputVariable, allowing you to reference the variable across stages and jobs. See: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=bash#set-an-output-variable-for-use-in-future-jobs.",
141+
"groupName": "backcompat"
142+
},
125143
{
126144
"name": "extensionVersionOverride",
127145
"type": "string",
@@ -150,12 +168,6 @@
150168
"groupName": "advanced"
151169
}
152170
],
153-
"outputVariables": [
154-
{
155-
"name": "Extension.Version",
156-
"description": "Is set with the calculated version number."
157-
}
158-
],
159171
"execution": {
160172
"Node": {
161173
"target": "ExtensionVersion/v3/ExtensionVersion.js",

BuildTasks/ExtensionVersion/v4/ExtensionVersion.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ function setVersion(version: string) {
1010
tl.command("build.updatebuildnumber", null, version);
1111
}
1212

13+
console.log("Setting local variable 'Extension.Version'.");
14+
tl.setVariable("Extension.Version", version, false, false);
15+
console.log("Setting output variable '{{StepName}}.Extension.Version'.");
1316
tl.setVariable("Extension.Version", version, false, true);
1417
}
1518

BuildTasks/ExtensionVersion/v4/task.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@
150150
"groupName": "advanced"
151151
}
152152
],
153-
"outputVariables": [
154-
{
155-
"name": "Extension.Version",
156-
"description": "Is set with the calculated version number."
157-
}
158-
],
159153
"execution": {
160154
"Node16": {
161155
"target": "ExtensionVersion/v4/ExtensionVersion.js",

0 commit comments

Comments
 (0)