You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| `ProjectId` | yes | The Id of the project where the build that must be retained can be found |
181
+
| `BuildId` | yes | The Id of the build that must be retained |
182
+
| `DaysToKeep` | no | The number of days to keep the Azure DevOps pipeline run, if not supplied the Azure DevOps pipeline run will be saved indefinitely |
182
183
183
184
**Example**
184
185
186
+
Saving an Azure DevOps pipeline run indefinitely
187
+
185
188
```powershell
186
189
PS> Save-AzDevOpsBuild `
187
190
-ProjectId $(System.TeamProjectId) `
188
191
-BuildId $(Build.BuildId)
189
-
# Saved Azure DevOps build with build ID $BuildId in project $ProjectId
192
+
# Saved Azure DevOps build indefinitely with build ID $BuildId in project $ProjectId
193
+
```
194
+
195
+
Saving an Azure DevOps pipeline run for 10 days
196
+
197
+
```powershell
198
+
PS> Save-AzDevOpsBuild `
199
+
-ProjectId $(System.TeamProjectId) `
200
+
-BuildId $(Build.BuildId) `
201
+
-DaysToKeep 10
202
+
# Saved Azure DevOps build for 10 days with build ID $BuildId in project $ProjectId
190
203
```
191
204
192
205
> 💡 The variables $(System.TeamProjectId) and $(Build.BuildId) are predefined Azure DevOps variables. Information on them can be found here: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
Write-Verbose"Saving Azure DevOps build for $daysValid days with build ID $BuildId in project $ProjectId by posting '$requestBody' to '$requestUri'..."
throw"Unable to retain Azure DevOps build indefinetely with build ID $BuildId in project $ProjectId. API request returned statuscode $($response.StatusCode)"
28
+
throw"Unable to retain Azure DevOps build with build ID $BuildId in project $ProjectId. API request returned statuscode $($response.StatusCode)"
24
29
}
25
30
26
-
Write-Host"Saved Azure DevOps build with build ID $BuildId in project $ProjectId"-ForegroundColor Green
31
+
if ($DaysToKeep-eq'') {
32
+
Write-Host"Saved Azure DevOps build indefinitely with build ID $BuildId in project $ProjectId"-ForegroundColor Green
33
+
} else {
34
+
Write-Host"Saved Azure DevOps build for $DaysToKeep days with build ID $BuildId in project $ProjectId"-ForegroundColor Green
0 commit comments