Skip to content

Commit

Permalink
Raise from enviroment added to transform
Browse files Browse the repository at this point in the history
  • Loading branch information
jessehouwing committed Sep 19, 2023
1 parent aeddbf9 commit de147cb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
3 changes: 1 addition & 2 deletions vsts-variable-set/v3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
"options": {
"value": "value",
"env": "env"
},
"aliases": ["variableName"]
}
},
{
"defaultValue": "",
Expand Down
32 changes: 28 additions & 4 deletions vsts-variable-transform/v3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,37 @@
}
],
"inputs": [
{
"defaultValue": "value",
"helpMarkdown": "Take the value from the input or an environment variable.",
"label": "From",
"name": "From",
"required": true,
"type": "pickList",
"options": {
"value": "value",
"env": "env"
}
},
{
"defaultValue": "",
"helpMarkdown": "Input value. You can use other variables as input as with any other text input using the `$(...)` notation anywhere in the value.",
"label": "Input Value",
"name": "value",
"helpMarkdown": "The value to assign to the variable.",
"label": "Value",
"name": "Value",
"required": false,
"type": "string"
"type": "string",
"aliases": ["value"],
"visibleRule": "From=value"
},
{
"defaultValue": "",
"helpMarkdown": "The value to assign to the variable.",
"label": "Environment Variable",
"name": "Env",
"required": true,
"type": "string",
"aliases": ["Env", "Environment"],
"visibleRule": "From=env"
},
{
"defaultValue": "",
Expand Down
24 changes: 23 additions & 1 deletion vsts-variable-transform/v3/vsts-variable-transform.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
import * as tl from "azure-pipelines-task-lib/task";

const transformAction = tl.getInput("transformAction", false) || "none";
let value = tl.getInput("value") || "";

function getValue()
{
const from = tl.getInput("From") || "value";
switch (from)
{
case "value":
{
return tl.getInput("Value");
}
case "env":
{
return process.env[tl.getInput("Env", true)];
}
default:
{
return "";
}
}
}

let value = getValue() || "";

const isSecret = tl.getBoolInput("isSecret") || false;
const useTaskLib = tl.getBoolInput("useTasklib") || false;
const variable = tl.getInput("variableName", true);
Expand Down

0 comments on commit de147cb

Please sign in to comment.