From 1c4d060138783f6b47d7a017a998c3b2dee72d85 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 6 Oct 2021 10:30:29 -0700 Subject: [PATCH] Add devops variable setting/clearing to eng/common (#18055) Co-authored-by: Daniel Jurek --- .../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