PowerShell/.pipelines/templates/SetVersionVariables.yml
Travis Plunk c83bd87e4f
Capture environment better (#24148)
* Capture environment better

* Capture env better
2024-09-05 14:49:23 -07:00

80 lines
2.8 KiB
YAML

parameters:
ReleaseTagVar: v6.2.0
ReleaseTagVarName: ReleaseTagVar
CreateJson: 'no'
UseJson: 'yes'
steps:
- ${{ if eq(parameters['UseJson'],'yes') }}:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: 'drop_prep_SetVars'
itemPattern: '*.json'
downloadPath: '$(System.ArtifactsDirectory)'
displayName: Download Build Info Json
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue
- powershell: |
$path = "./build.psm1"
if($env:REPOROOT){
Write-Verbose "reporoot already set to ${env:REPOROOT}" -Verbose
exit 0
}
if(Test-Path -Path $path)
{
Write-Verbose "reporoot detect at: ." -Verbose
$repoRoot = '.'
}
else{
$path = "./PowerShell/build.psm1"
if(Test-Path -Path $path)
{
Write-Verbose "reporoot detect at: ./PowerShell" -Verbose
$repoRoot = './PowerShell'
}
}
if($repoRoot) {
$vstsCommandString = "vso[task.setvariable variable=repoRoot]$repoRoot"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
} else {
Write-Verbose -Verbose "repo not found"
}
displayName: 'Set repo Root'
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue
- powershell: |
$createJson = ("${{ parameters.CreateJson }}" -ne "no")
$REPOROOT = $env:REPOROOT
if (-not (Test-Path $REPOROOT/tools/releaseBuild/setReleaseTag.ps1)) {
if ((Test-Path "$REPOROOT/PowerShell/tools/releaseBuild/setReleaseTag.ps1")) {
$REPOROOT = "$REPOROOT/PowerShell"
} else {
throw "Could not find setReleaseTag.ps1 in $REPOROOT/tools/releaseBuild or $REPOROOT/PowerShell/tools/releaseBuild"
}
}
$releaseTag = & "$REPOROOT/tools/releaseBuild/setReleaseTag.ps1" -ReleaseTag ${{ parameters.ReleaseTagVar }} -Variable "${{ parameters.ReleaseTagVarName }}" -CreateJson:$createJson
$version = $releaseTag.Substring(1)
$vstsCommandString = "vso[task.setvariable variable=Version]$version"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
$azureVersion = $releaseTag.ToLowerInvariant() -replace '\.', '-'
$vstsCommandString = "vso[task.setvariable variable=AzureVersion]$azureVersion"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
displayName: 'Set ${{ parameters.ReleaseTagVarName }} and other version Variables'
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue
- powershell: |
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
displayName: Capture environment
condition: succeededOrFailed()
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue