Skip to content

Commit

Permalink
Add devops variable setting/clearing to eng/common (#18055)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Jurek <[email protected]>
  • Loading branch information
azure-sdk and danieljurek authored Oct 6, 2021
1 parent 524edff commit 1c4d060
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
20 changes: 20 additions & 0 deletions eng/common/pipelines/templates/steps/devops-variables-clear.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions eng/common/pipelines/templates/steps/devops-variables-set.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1c4d060

Please sign in to comment.