Skip to content

Commit

Permalink
Raise variable from enviroment
Browse files Browse the repository at this point in the history
  • Loading branch information
jessehouwing committed Sep 19, 2023
1 parent fa5f939 commit aeddbf9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
26 changes: 25 additions & 1 deletion vsts-variable-set/v3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,38 @@
"required": false,
"visibleRule": "VariableName=release.releasename"
},
{
"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"
},
"aliases": ["variableName"]
},
{
"defaultValue": "",
"helpMarkdown": "The value to assign to the variable.",
"label": "Value",
"name": "Value",
"required": false,
"type": "string",
"aliases": ["value"]
"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": false,
Expand Down
23 changes: 22 additions & 1 deletion vsts-variable-set/v3/vsts-variable-set.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import * as tl from "azure-pipelines-task-lib/task";

const variable = tl.getInput("VariableName", true);
const 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 "";
}
}
}

const value = getValue()
const isSecret = tl.getBoolInput("isSecret") || false;
const useTaskLib = tl.getBoolInput("useTasklib") || false;
const useSetVariableForReleaseName = tl.getBoolInput("useSetVariableForReleaseName") || false;
Expand Down

0 comments on commit aeddbf9

Please sign in to comment.