Skip to content

Commit de147cb

Browse files
committed
Raise from enviroment added to transform
1 parent aeddbf9 commit de147cb

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed

vsts-variable-set/v3/task.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
"options": {
6161
"value": "value",
6262
"env": "env"
63-
},
64-
"aliases": ["variableName"]
63+
}
6564
},
6665
{
6766
"defaultValue": "",

vsts-variable-transform/v3/task.json

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,37 @@
3434
}
3535
],
3636
"inputs": [
37+
{
38+
"defaultValue": "value",
39+
"helpMarkdown": "Take the value from the input or an environment variable.",
40+
"label": "From",
41+
"name": "From",
42+
"required": true,
43+
"type": "pickList",
44+
"options": {
45+
"value": "value",
46+
"env": "env"
47+
}
48+
},
3749
{
3850
"defaultValue": "",
39-
"helpMarkdown": "Input value. You can use other variables as input as with any other text input using the `$(...)` notation anywhere in the value.",
40-
"label": "Input Value",
41-
"name": "value",
51+
"helpMarkdown": "The value to assign to the variable.",
52+
"label": "Value",
53+
"name": "Value",
4254
"required": false,
43-
"type": "string"
55+
"type": "string",
56+
"aliases": ["value"],
57+
"visibleRule": "From=value"
58+
},
59+
{
60+
"defaultValue": "",
61+
"helpMarkdown": "The value to assign to the variable.",
62+
"label": "Environment Variable",
63+
"name": "Env",
64+
"required": true,
65+
"type": "string",
66+
"aliases": ["Env", "Environment"],
67+
"visibleRule": "From=env"
4468
},
4569
{
4670
"defaultValue": "",

vsts-variable-transform/v3/vsts-variable-transform.ts

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

33
const transformAction = tl.getInput("transformAction", false) || "none";
4-
let 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+
let value = getValue() || "";
26+
527
const isSecret = tl.getBoolInput("isSecret") || false;
628
const useTaskLib = tl.getBoolInput("useTasklib") || false;
729
const variable = tl.getInput("variableName", true);

0 commit comments

Comments
 (0)