Skip to content

Commit aeddbf9

Browse files
committed
Raise variable from enviroment
1 parent fa5f939 commit aeddbf9

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

vsts-variable-set/v3/task.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,38 @@
5050
"required": false,
5151
"visibleRule": "VariableName=release.releasename"
5252
},
53+
{
54+
"defaultValue": "value",
55+
"helpMarkdown": "Take the value from the input or an environment variable.",
56+
"label": "From",
57+
"name": "From",
58+
"required": true,
59+
"type": "pickList",
60+
"options": {
61+
"value": "value",
62+
"env": "env"
63+
},
64+
"aliases": ["variableName"]
65+
},
5366
{
5467
"defaultValue": "",
5568
"helpMarkdown": "The value to assign to the variable.",
5669
"label": "Value",
5770
"name": "Value",
5871
"required": false,
5972
"type": "string",
60-
"aliases": ["value"]
73+
"aliases": ["value"],
74+
"visibleRule": "From=value"
75+
},
76+
{
77+
"defaultValue": "",
78+
"helpMarkdown": "The value to assign to the variable.",
79+
"label": "Environment Variable",
80+
"name": "Env",
81+
"required": true,
82+
"type": "string",
83+
"aliases": ["Env", "Environment"],
84+
"visibleRule": "From=env"
6185
},
6286
{
6387
"defaultValue": false,

vsts-variable-set/v3/vsts-variable-set.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
import * as tl from "azure-pipelines-task-lib/task";
22

33
const variable = tl.getInput("VariableName", true);
4-
const value = tl.getInput("Value");
4+
5+
function getValue()
6+
{
7+
const from = tl.getInput("From") || "value";
8+
switch (from)
9+
{
10+
case "value":
11+
{
12+
return tl.getInput("Value");
13+
}
14+
case "env":
15+
{
16+
return process.env[tl.getInput("Env", true)];
17+
}
18+
default:
19+
{
20+
return "";
21+
}
22+
}
23+
}
24+
25+
const value = getValue()
526
const isSecret = tl.getBoolInput("isSecret") || false;
627
const useTaskLib = tl.getBoolInput("useTasklib") || false;
728
const useSetVariableForReleaseName = tl.getBoolInput("useSetVariableForReleaseName") || false;

0 commit comments

Comments
 (0)