-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ABZU-69885-Add lease to pipeline (#191)
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Param( | ||
[Parameter(mandatory=$true)][int]$daysValid, | ||
[Parameter(mandatory=$true)][string]$accessToken, | ||
[Parameter(mandatory=$true)][int]$definitionId, | ||
[Parameter(mandatory=$true)][string]$ownerId, | ||
[Parameter(mandatory=$true)][int]$buildId, | ||
[Parameter(mandatory=$true)][string]$collectionUri, | ||
[Parameter(mandatory=$true)][string]$teamProject | ||
) | ||
|
||
try{ | ||
$contentType = "application/json"; | ||
$headers = @{ Authorization = 'Bearer $accessToken' }; | ||
$rawRequest = @{ daysValid = $daysValid; definitionId = $definitionId; ownerId = $ownerId; protectPipeline = $false; runId = $buildId }; | ||
$request = ConvertTo-Json @($rawRequest); | ||
$uri = "$collectionUri$teamProject/_apis/build/retention/leases?api-version=7.0"; | ||
|
||
Write-Host $request | ||
Write-Host $uri | ||
|
||
Invoke-RestMethod -uri $uri -method POST -Headers $headers -ContentType $contentType -Body $request; | ||
|
||
Write-Host "Pipeline will be retained for $daysValid days" | ||
} | ||
catch{ | ||
Write-Host $_ | ||
Write-Host "##vso[task.complete result=SucceededWithIssues;]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
steps: | ||
- task: PowerShell@2 | ||
condition: and(succeeded(), not(canceled())) | ||
displayName: Retain Live Release | ||
inputs: | ||
targetType: filePath | ||
filePath: "$(Build.SourcesDirectory)/Deployment/add-lease.ps1" | ||
arguments: "-daysValid 365 | ||
-accessToken '$(System.AccessToken)' | ||
-definitionId $(System.DefinitionId) | ||
-ownerId 'User:$(Build.RequestedForId)' | ||
-buildId $(Build.BuildId) | ||
-collectionUri '$(System.CollectionUri)' | ||
-teamProject '$(System.TeamProject)'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters