Skip to content

Commit

Permalink
Add devops variable setting/clearing to eng/common (#2952)
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 975ad22 commit aab2b79
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 aab2b79

Please sign in to comment.