From af6266bc1e051fb337cc2f7d39ae19901f017958 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Wed, 6 Oct 2021 10:32:56 -0700 Subject: [PATCH] Add devops variable setting/clearing to eng/common (#2068) --- .../steps/devops-variables-clear.yml | 20 ++++++++++++++++++ .../templates/steps/devops-variables-set.yml | 21 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 eng/common/pipelines/templates/steps/devops-variables-clear.yml create mode 100644 eng/common/pipelines/templates/steps/devops-variables-set.yml diff --git a/eng/common/pipelines/templates/steps/devops-variables-clear.yml b/eng/common/pipelines/templates/steps/devops-variables-clear.yml new file mode 100644 index 00000000000..67f33dab014 --- /dev/null +++ b/eng/common/pipelines/templates/steps/devops-variables-clear.yml @@ -0,0 +1,20 @@ +parameters: +- name: Variables + type: object + default: [] +- name: ContinueOnError + type: boolean + default: false + +steps: + - pwsh: | + $rawVariables = @" + ${{ convertToJson(parameters.Variables) }} + "@ + $variables = ConvertFrom-Json $rawVariables -AsHashtable + foreach ($key in $variables.Keys) { + Write-Host "Clearing: $key" + Write-Host "##vso[task.setvariable variable=$key]" + } + continueOnError: ${{ parameters.ContinueOnError }} + displayName: Clear DevOps Variables \ No newline at end of file diff --git a/eng/common/pipelines/templates/steps/devops-variables-set.yml b/eng/common/pipelines/templates/steps/devops-variables-set.yml new file mode 100644 index 00000000000..f31641eae0b --- /dev/null +++ b/eng/common/pipelines/templates/steps/devops-variables-set.yml @@ -0,0 +1,21 @@ +parameters: + - name: Variables + type: object + default: [] + - name: ContinueOnError + type: boolean + default: false + +steps: + - pwsh: | + $rawVariables = @" + ${{ convertToJson(parameters.Variables) }} + "@ + $variables = ConvertFrom-Json $rawVariables -AsHashtable + foreach ($key in $variables.Keys) { + $value = $variables[$key] + Write-Host "Setting: $key = $value" + Write-Host "##vso[task.setvariable variable=$key]$value" + } + continueOnError: ${{ parameters.ContinueOnError }} + displayName: Set DevOps Variables \ No newline at end of file