diff options
author | Andrew Arnott <andrewarnott@live.com> | 2021-05-30 04:09:48 +0300 |
---|---|---|
committer | Andrew Arnott <andrewarnott@live.com> | 2021-05-30 04:09:56 +0300 |
commit | bbda765e7b3bdfd104548f07ff26a2291ce2b6af (patch) | |
tree | 8629e85ce07d3534ca5be22a79f109f87060a007 /azure-pipelines | |
parent | 83f7cb6ea003b289ff70783e1de1fa12edab0f2c (diff) |
Update from Library.Template
Fixes #1244
Diffstat (limited to 'azure-pipelines')
-rw-r--r-- | azure-pipelines/Get-TempToolsPath.ps1 | 6 | ||||
-rw-r--r-- | azure-pipelines/Get-nbgv.ps1 | 6 | ||||
-rw-r--r-- | azure-pipelines/Set-EnvVars.ps1 | 79 | ||||
-rw-r--r-- | azure-pipelines/install-dependencies.yml | 6 | ||||
-rw-r--r-- | azure-pipelines/release.yml | 1 | ||||
-rw-r--r-- | azure-pipelines/variables/_pipelines.ps1 | 9 |
6 files changed, 17 insertions, 90 deletions
diff --git a/azure-pipelines/Get-TempToolsPath.ps1 b/azure-pipelines/Get-TempToolsPath.ps1 index 97c552c0..bb3da8e3 100644 --- a/azure-pipelines/Get-TempToolsPath.ps1 +++ b/azure-pipelines/Get-TempToolsPath.ps1 @@ -1,7 +1,7 @@ -if ($env:AGENT_TOOLSDIRECTORY) { - $path = "$env:AGENT_TOOLSDIRECTORY\vs-platform\tools" +if ($env:AGENT_TEMPDIRECTORY) { + $path = "$env:AGENT_TEMPDIRECTORY\$env:BUILD_BUILDID" } elseif ($env:localappdata) { - $path = "$env:localappdata\vs-platform\tools" + $path = "$env:localappdata\gitrepos\tools" } else { $path = "$PSScriptRoot\..\obj\tools" } diff --git a/azure-pipelines/Get-nbgv.ps1 b/azure-pipelines/Get-nbgv.ps1 index 925eecdd..a5be2cf7 100644 --- a/azure-pipelines/Get-nbgv.ps1 +++ b/azure-pipelines/Get-nbgv.ps1 @@ -10,11 +10,7 @@ if ($existingTool) { return $existingTool.Path } -if ($env:AGENT_TEMPDIRECTORY) { - $toolInstallDir = "$env:AGENT_TEMPDIRECTORY/$env:BUILD_BUILDID" -} else { - $toolInstallDir = "$PSScriptRoot/../obj/tools" -} +$toolInstallDir = & "$PSScriptRoot/Get-TempToolsPath.ps1" $toolPath = "$toolInstallDir/nbgv" if (!(Test-Path $toolInstallDir)) { New-Item -Path $toolInstallDir -ItemType Directory | Out-Null } diff --git a/azure-pipelines/Set-EnvVars.ps1 b/azure-pipelines/Set-EnvVars.ps1 deleted file mode 100644 index 9d14d9aa..00000000 --- a/azure-pipelines/Set-EnvVars.ps1 +++ /dev/null @@ -1,79 +0,0 @@ -<# -.SYNOPSIS - Set environment variables in the environment. - Azure Pipeline and CMD environments are considered. -.PARAMETER Variables - A hashtable of variables to be set. -.OUTPUTS - A boolean indicating whether the environment variables can be expected to propagate to the caller's environment. -#> -[CmdletBinding(SupportsShouldProcess=$true)] -Param( - [Parameter(Mandatory=$true, Position=1)] - $Variables, - [string[]]$PrependPath -) - -if ($Variables.Count -eq 0) { - return $true -} - -$cmdInstructions = !$env:TF_BUILD -and !$env:GITHUB_ACTIONS -and $env:PS1UnderCmd -eq '1' -if ($cmdInstructions) { - Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe" - Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue -} else { - Write-Host "Environment variables set:" -ForegroundColor Blue - Write-Host ($Variables | Out-String) - if ($PrependPath) { - Write-Host "Paths prepended to PATH: $PrependPath" - } -} - -if ($env:TF_BUILD) { - Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path." -} - -if ($env:GITHUB_ACTIONS) { - Write-Host "GitHub Actions detected. Logging commands will be used to propagate environment variables and prepend path." -} - -$Variables.GetEnumerator() |% { - Set-Item -Path env:$($_.Key) -Value $_.Value - - # If we're running in a cloud CI, set these environment variables so they propagate. - if ($env:TF_BUILD) { - Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" - } - if ($env:GITHUB_ACTIONS) { - Write-Host "::set-env name=$($_.Key)::$($_.Value)" - } - - if ($cmdInstructions) { - Write-Host "SET $($_.Key)=$($_.Value)" - } -} - -$pathDelimiter = ';' -if ($IsMacOS -or $IsLinux) { - $pathDelimiter = ':' -} - -if ($PrependPath) { - $PrependPath |% { - $newPathValue = "$_$pathDelimiter$env:PATH" - Set-Item -Path env:PATH -Value $newPathValue - if ($cmdInstructions) { - Write-Host "SET PATH=$newPathValue" - } - - if ($env:TF_BUILD) { - Write-Host "##vso[task.prependpath]$_" - } - if ($env:GITHUB_ACTIONS) { - Write-Host "::add-path::$_" - } - } -} - -return !$cmdInstructions diff --git a/azure-pipelines/install-dependencies.yml b/azure-pipelines/install-dependencies.yml index 5b1ac4af..7563bc1f 100644 --- a/azure-pipelines/install-dependencies.yml +++ b/azure-pipelines/install-dependencies.yml @@ -7,8 +7,14 @@ steps: $AccessToken = '$(System.AccessToken)' # Avoid specifying the access token directly on the init.ps1 command line to avoid it showing up in errors .\init.ps1 -AccessToken $AccessToken ${{ parameters['initArgs'] }} -UpgradePrerequisites dotnet --info + + # Print mono version if it is present. + if (Get-Command mono -ErrorAction SilentlyContinue) { + mono --version + } displayName: Install prerequisites - powershell: azure-pipelines/variables/_pipelines.ps1 failOnStderr: true displayName: Set pipeline variables based on source + name: SetPipelineVariables diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index 4f6ebd82..316655a8 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -21,6 +21,7 @@ stages: runOnce: deploy: steps: + - download: none - powershell: | Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)" displayName: Set pipeline name diff --git a/azure-pipelines/variables/_pipelines.ps1 b/azure-pipelines/variables/_pipelines.ps1 index 14d6ffc2..867b7fc8 100644 --- a/azure-pipelines/variables/_pipelines.ps1 +++ b/azure-pipelines/variables/_pipelines.ps1 @@ -8,13 +8,16 @@ # Always use ALL CAPS for env var names since Azure Pipelines converts variable names to all caps and on non-Windows OS, env vars are case sensitive. $keyCaps = $_.Key.ToUpper() if (Test-Path -Path "env:$keyCaps") { - Write-Host "Skipping setting $keyCaps because variable is already set." -ForegroundColor Cyan + Write-Host "Skipping setting $keyCaps because variable is already set to '$(Get-Content env:$keyCaps)'." -ForegroundColor Cyan } else { Write-Host "$keyCaps=$($_.Value)" -ForegroundColor Yellow if ($env:TF_BUILD) { - Write-Host "##vso[task.setvariable variable=$keyCaps;]$($_.Value)" + # Create two variables: the first that can be used by its simple name and accessible only within this job. + Write-Host "##vso[task.setvariable variable=$keyCaps]$($_.Value)" + # and the second that works across jobs and stages but must be fully qualified when referenced. + Write-Host "##vso[task.setvariable variable=$keyCaps;isOutput=true]$($_.Value)" } elseif ($env:GITHUB_ACTIONS) { - Write-Host "::set-env name=$keyCaps::$($_.Value)" + Add-Content -Path $env:GITHUB_ENV -Value "$keyCaps=$($_.Value)" } Set-Item -Path "env:$keyCaps" -Value $_.Value } |