diff --git a/.vsts-ci/linux.yml b/.vsts-ci/linux.yml index 832fd6a4e6..a7f9e85d84 100644 --- a/.vsts-ci/linux.yml +++ b/.vsts-ci/linux.yml @@ -93,7 +93,7 @@ jobs: - powershell: | $ErrorActionPreference = 'continue' - tools/travis.ps1 + tools/travis.ps1 -NugetKey $(NUGET_KEY) displayName: Build and test condition: succeeded() diff --git a/.vsts-ci/windows.yml b/.vsts-ci/windows.yml index 8da74c3867..9e1f428d24 100644 --- a/.vsts-ci/windows.yml +++ b/.vsts-ci/windows.yml @@ -94,6 +94,6 @@ steps: - powershell: | Import-Module .\tools\Appveyor.psm1 Restore-PSOptions - Invoke-AppveyorFinish + Invoke-AppveyorFinish -NuGetKey $(NUGET_KEY) displayName: Finish condition: eq(variables['Purpose'], 'ElevatedPesterTests_xUnit_Packaging') diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index fffb564b27..e2bb107fdc 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -579,6 +579,10 @@ function Get-ReleaseTag # Implements AppVeyor 'on_finish' step function Invoke-AppveyorFinish { + param( + [string] $NuGetKey + ) + try { $releaseTag = Get-ReleaseTag @@ -664,10 +668,10 @@ function Invoke-AppveyorFinish Write-Warning "Artifact $_ does not exist." } - if($env:NUGET_KEY -and $env:NUGET_URL -and [system.io.path]::GetExtension($_) -ieq '.nupkg') + if($NuGetKey -and $env:NUGET_URL -and [system.io.path]::GetExtension($_) -ieq '.nupkg') { Write-Log "pushing $_ to $env:NUGET_URL" - Start-NativeExecution -sb {dotnet nuget push $_ --api-key $env:NUGET_KEY --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode + Start-NativeExecution -sb {dotnet nuget push $_ --api-key $NuGetKey --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode } } if(!$pushedAllArtifacts) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 20ccfec295..9717654f2a 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -2,7 +2,8 @@ # Licensed under the MIT License. param( [ValidateSet('Bootstrap','Build','Failure','Success')] - [String]$Stage = 'Build' + [String]$Stage = 'Build', + [String]$NugetKey ) Import-Module $PSScriptRoot/../build.psm1 -Force @@ -362,10 +363,10 @@ elseif($Stage -eq 'Build') # 1 - It's a Daily build (already checked, for not a PR) # 2 - We have the info to publish (NUGET_KEY and NUGET_URL) # 3 - it's a nupkg file - if($isDailyBuild -and $env:NUGET_KEY -and $env:NUGET_URL -and [system.io.path]::GetExtension($package) -ieq '.nupkg') + if($isDailyBuild -and $NugetKey -and $env:NUGET_URL -and [system.io.path]::GetExtension($package) -ieq '.nupkg') { Write-Log "pushing $package to $env:NUGET_URL" - Start-NativeExecution -sb {dotnet nuget push $package --api-key $env:NUGET_KEY --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode + Start-NativeExecution -sb {dotnet nuget push $package --api-key $NugetKey --source "$env:NUGET_URL/api/v2/package"} -IgnoreExitcode } } if ($IsLinux)