@@ -12,28 +12,33 @@ param(
1212 [Parameter (Mandatory = $true )]
1313 [int ]$RunId ,
1414
15- [Parameter (Mandatory = $true )]
16- [string ]$OwnerId ,
17-
1815 [Parameter (Mandatory = $true )]
1916 [int ]$DaysValid ,
2017
21- [Parameter (Mandatory = $true )]
22- [string ]$AccessToken
18+ [Parameter (Mandatory = $false )]
19+ [string ]$OwnerId = " azure-sdk-pipeline-automation" ,
20+
21+ [Parameter (Mandatory = $false )]
22+ [string ]$AccessToken = $env: DEVOPS_PAT
2323)
2424
25+ Set-StrictMode - Version 3
26+
27+ . (Join-Path $PSScriptRoot common.ps1)
28+
2529$unencodedAuthToken = " nobody:$AccessToken "
2630$unencodedAuthTokenBytes = [System.Text.Encoding ]::UTF8.GetBytes($unencodedAuthToken )
2731$encodedAuthToken = [System.Convert ]::ToBase64String($unencodedAuthTokenBytes )
2832
29- # We are doing this here so that there is zero chance that this token is emitted in Azure Pipelines
30- # build logs. Azure Pipelines will see this text and register the secret as a value it should *** out
31- # before being transmitted to the server (and shown in logs). It means if the value is accidentally
32- # leaked anywhere else that it won't be visible. The downside is that when the script is executed
33- # on a local development box, it will be visible.
34- Write-Host " ##vso[task.setvariable variable=_throwawayencodedaccesstoken;issecret=true;]$ ( $encodedAuthToken ) "
33+ if ($isDevOpsRun ) {
34+ # We are doing this here so that there is zero chance that this token is emitted in Azure Pipelines
35+ # build logs. Azure Pipelines will see this text and register the secret as a value it should *** out
36+ # before being transmitted to the server (and shown in logs). It means if the value is accidentally
37+ # leaked anywhere else that it won't be visible. The downside is that when the script is executed
38+ # on a local development box, it will be visible.
39+ Write-Host " ##vso[task.setvariable variable=_throwawayencodedaccesstoken;issecret=true;]$ ( $encodedAuthToken ) "
40+ }
3541
36- . (Join-Path $PSScriptRoot common.ps1)
3742
3843LogDebug " Checking for existing leases on run: $RunId "
3944$existingLeases = Get-RetentionLeases - Organization $Organization - Project $Project - DefinitionId $DefinitionId - RunId $RunId - OwnerId $OwnerId - Base64EncodedAuthToken $encodedAuthToken
0 commit comments