@@ -12,28 +12,33 @@ param(
12
12
[Parameter (Mandatory = $true )]
13
13
[int ]$RunId ,
14
14
15
- [Parameter (Mandatory = $true )]
16
- [string ]$OwnerId ,
17
-
18
15
[Parameter (Mandatory = $true )]
19
16
[int ]$DaysValid ,
20
17
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
23
23
)
24
24
25
+ Set-StrictMode - Version 3
26
+
27
+ . (Join-Path $PSScriptRoot common.ps1)
28
+
25
29
$unencodedAuthToken = " nobody:$AccessToken "
26
30
$unencodedAuthTokenBytes = [System.Text.Encoding ]::UTF8.GetBytes($unencodedAuthToken )
27
31
$encodedAuthToken = [System.Convert ]::ToBase64String($unencodedAuthTokenBytes )
28
32
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
+ }
35
41
36
- . (Join-Path $PSScriptRoot common.ps1)
37
42
38
43
LogDebug " Checking for existing leases on run: $RunId "
39
44
$existingLeases = Get-RetentionLeases - Organization $Organization - Project $Project - DefinitionId $DefinitionId - RunId $RunId - OwnerId $OwnerId - Base64EncodedAuthToken $encodedAuthToken
0 commit comments