From ac29bd30f5fdd8d4b449545bbc9e8e7451a85556 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 13 Jan 2022 16:14:27 -0700 Subject: [PATCH] Retain builds that are inserted to VS This retains builds for 2 years as required for SBOM preservation. It also solves our older problem of builds disappearing before we can push them to nuget.org and github releases. --- azure-pipelines/vs-insertion.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/azure-pipelines/vs-insertion.yml b/azure-pipelines/vs-insertion.yml index 5bcf19e4..729386cc 100644 --- a/azure-pipelines/vs-insertion.yml +++ b/azure-pipelines/vs-insertion.yml @@ -49,3 +49,12 @@ stages: AutoCompleteMergeStrategy: Squash - task: MicroBuildCleanup@1 displayName: Send Telemetry + - powershell: | + $contentType = 'application/json'; + $headers = @{ Authorization = 'Bearer $(System.AccessToken)' }; + $rawRequest = @{ daysValid = 365 * 2; definitionId = $(resources.pipeline.CI.pipelineID); ownerId = 'User:$(Build.RequestedForId)'; protectPipeline = $false; runId = $(resources.pipeline.CI.runId) }; + $request = ConvertTo-Json @($rawRequest); + Write-Host $request + $uri = "$(System.CollectionUri)$(System.TeamProject)/_apis/build/retention/leases?api-version=6.0-preview.1"; + Invoke-RestMethod -uri $uri -method POST -Headers $headers -ContentType $contentType -Body $request; + displayName: Retain inserted builds