Skip to content

Commit

Permalink
Add devops variable setting/clearing to eng/common (#2068)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljurek authored Oct 6, 2021
1 parent e8a895e commit af6266b
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 af6266b

Please sign in to comment.