From ba379f5e16c0fc611ab0bbef48bc9078b6bcc2d0 Mon Sep 17 00:00:00 2001 From: Daniel Jurek Date: Mon, 4 Oct 2021 15:42:09 -0700 Subject: [PATCH] Add devops variable setting/clearing to eng/common --- .../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 000000000000..67f33dab0146 --- /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 000000000000..f31641eae0b5 --- /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