-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements in Pipeline parameters (#2748)
* Improvements in Pipeline parameters * remove extra space * fix jq --------- Co-authored-by: narrieta <narrieta>
- Loading branch information
Showing
6 changed files
with
134 additions
and
131 deletions.
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
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
This file was deleted.
Oops, something went wrong.
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,56 @@ | ||
# | ||
# Pipeline for cleaning up any remaining Resource Groups generated by the Azure.WALinuxAgent pipeline. | ||
# | ||
# Runs every 3 hours and deletes any resource groups that are more than a day old and contain string "lisa-WALinuxAgent-" | ||
# | ||
schedules: | ||
- cron: "0 */3 * * *" # Run every 3 hours | ||
displayName: cleanup build | ||
branches: | ||
include: | ||
- develop | ||
always: true | ||
|
||
# no PR triggers | ||
pr: none | ||
|
||
pool: | ||
vmImage: ubuntu-latest | ||
|
||
variables: | ||
- name: azureConnection | ||
value: 'azuremanagement' | ||
- name: rgPrefix | ||
value: 'lisa-WALinuxAgent-' | ||
|
||
steps: | ||
|
||
- task: AzureKeyVault@2 | ||
displayName: "Fetch secrets from KV" | ||
inputs: | ||
azureSubscription: '$(azureConnection)' | ||
KeyVaultName: 'dcrV2SPs' | ||
SecretsFilter: '*' | ||
RunAsPreJob: true | ||
|
||
- task: AzureCLI@2 | ||
inputs: | ||
azureSubscription: '$(azureConnection)' | ||
scriptType: 'bash' | ||
scriptLocation: 'inlineScript' | ||
inlineScript: | | ||
set -euxo pipefail | ||
date=`date --utc +%Y-%m-%d'T'%H:%M:%S.%N'Z' -d "1 day ago"` | ||
# Using the Azure REST GET resourceGroups API call as we can add the createdTime to the results. | ||
# This feature is not available via the az-cli commands directly so we have to use the Azure REST APIs | ||
|
||
az rest --method GET \ | ||
--url "https://management.azure.com/subscriptions/$(SUBSCRIPTION-ID)/resourcegroups" \ | ||
--url-parameters api-version=2021-04-01 \$expand=createdTime \ | ||
--output json \ | ||
--query value \ | ||
| jq --arg date "$date" '.[] | select (.createdTime < $date).name' \ | ||
| grep "$(rgPrefix)" \ | ||
| xargs -l -t -r az group delete --no-wait -y -n \ | ||
|| echo "No resource groups found to delete" |
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
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