-
Notifications
You must be signed in to change notification settings - Fork 437
[CI Environment] Added scheduled pipelines for Subscription & Management-Group Deployment removals #2310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[CI Environment] Added scheduled pipelines for Subscription & Management-Group Deployment removals #2310
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
02542c1
Merge pull request #3 from Azure/main
AlexanderSehr b8483d7
Merge pull request #5 from Azure/main
AlexanderSehr 54a1bf2
Merge branch 'main' of https://github.com/MrMCake/ResourceModules
AlexanderSehr 39511c3
Added forms
AlexanderSehr 2d7616b
Update issue templates
AlexanderSehr c193bb3
Re-apply
AlexanderSehr e5709c7
Update issue templates
AlexanderSehr 3ff3629
Update to latest
AlexanderSehr 4fdbb63
Update to latest
AlexanderSehr 499672f
Updated forms
AlexanderSehr 8b5228b
Updated templates
AlexanderSehr 175d492
Updated templates
AlexanderSehr c54a11e
Update .github/ISSUE_TEMPLATE/bug_report.yml
AlexanderSehr a517f66
Update .github/PULL_REQUEST_TEMPLATE.md
AlexanderSehr 6b41e83
Merge branch 'Azure:main' into main
AlexanderSehr 50a2018
Update to latest
AlexanderSehr c5449be
Update to latest
AlexanderSehr 4a39f41
Merge pull request #8 from MrMCake/users/alsehr/maintenanceWorkflows
AlexanderSehr d9cc96f
Merge branch 'Azure:main' into main
AlexanderSehr 2061048
Added pipeline to auto-assign issues
AlexanderSehr 3f077f3
Update platform.issueAssignment.yml
AlexanderSehr 4690418
Update platform.issueAssignment.yml
AlexanderSehr e56b1a5
Update platform.issueAssignment.yml
AlexanderSehr 89aad7c
Delete platform.bug.yml
AlexanderSehr dd2b3ec
Delete platform.issueAssignment.yml
AlexanderSehr 70eadfb
Merge branch 'Azure:main' into main
AlexanderSehr de4471f
Merge branch 'Azure:main' into main
AlexanderSehr 45bf842
Merge branch 'Azure:main' into main
AlexanderSehr 072f03b
Merge branch 'Azure:main' into main
AlexanderSehr c1a51b1
Merge branch 'Azure:main' into main
AlexanderSehr 56192af
Added cleanup pipeline IP
AlexanderSehr c05148a
Moved setting to runtime parameter
AlexanderSehr de7cb68
Update to latest
AlexanderSehr c2f8857
Update to latest
AlexanderSehr 319b339
Adjusted output handling
AlexanderSehr e7d74b4
Update to latest
AlexanderSehr 2dd480e
Update to latest
AlexanderSehr 319393f
Updated Analysis services to different pipeline syntax
AlexanderSehr da5ca8a
Additional FromJSON
AlexanderSehr 55e8c19
rollback on test file paths
AlexanderSehr f5ef037
Updated pipelines
AlexanderSehr 495bdd7
Update .azuredevops/platformPipelines/platform.deployment.removal.yml
AlexanderSehr 8bc5ef5
Updated desc
AlexanderSehr af10ffb
Added ref
AlexanderSehr f4d1d0e
Update to latest
AlexanderSehr 9295d37
Update to latest
AlexanderSehr fa59fb1
Added example
AlexanderSehr 3174c6e
Update to latest
AlexanderSehr d478067
Update to latest
AlexanderSehr 7a47631
Update to latest
AlexanderSehr 93ea332
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr c11c349
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr c95aacf
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr 2023b81
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr e811f2e
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr 2558e6e
Update docs/wiki/The CI environment - Deployment removal.md
AlexanderSehr ea0ef59
Update docs/wiki/The CI environment.md
AlexanderSehr 5646dd1
Update .github/actions/templates/getWorkflowInput/action.yml
AlexanderSehr 26ba983
Update utilities/pipelines/deploymentRemoval/Clear-SubscriptionDeploy…
AlexanderSehr de610e7
Update utilities/pipelines/deploymentRemoval/Clear-ManagementGroupDep…
AlexanderSehr 5ed1be7
Renamed file
AlexanderSehr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
.azuredevops/platformPipelines/platform.deployment.removal.yml
This file contains hidden or 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,125 @@ | ||
| name: '.Platform - Remove Deployments' | ||
|
|
||
| parameters: | ||
| - name: handleSubscriptionScope | ||
| displayName: Include Subscription deployments | ||
| type: boolean | ||
| default: true # Note: This requires your service principal to have permissions on the subscription scope. | ||
| - name: handleManagementGroupScope | ||
| displayName: Include Management Group deployments | ||
| type: boolean | ||
| default: true # Note: This requires your service principal to have permissions on the management group scope. | ||
| - name: maxDeploymentRetentionInDays | ||
| displayName: The number of days to keep deployments with status [running] or [failed] | ||
| type: number | ||
| default: 14 | ||
|
|
||
| schedules: | ||
| - cron: "0 0 * * *" | ||
| displayName: Nightly run | ||
| branches: | ||
| include: | ||
| - main | ||
|
|
||
| pr: none | ||
|
|
||
| variables: | ||
| - template: '../../settings.yml' | ||
| - group: 'PLATFORM_VARIABLES' | ||
|
|
||
| jobs: | ||
| - job: Remove_Subscription_Deployments | ||
| condition: and(succeeded(), eq('${{ parameters.handleSubscriptionScope }}', 'true')) | ||
| displayName: Remove Subscription deployments | ||
| pool: | ||
| ${{ if eq(variables['vmImage'], '') }}: | ||
| name: $(poolName) | ||
| ${{ if eq(variables['poolName'], '') }}: | ||
| vmImage: $(vmImage) | ||
| steps: | ||
| - checkout: self | ||
| - task: PowerShell@2 | ||
| displayName: 'Setup agent for deployment' | ||
| inputs: | ||
| targetType: inline | ||
| pwsh: true | ||
| script: | | ||
| # Load used functions | ||
| . (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1') | ||
|
|
||
| # Define PS modules to install on the runner | ||
| $Modules = @( | ||
| @{ Name = 'Az.Accounts' } | ||
| ) | ||
|
|
||
| # Set agent up | ||
| Set-EnvironmentOnAgent -PSModules $Modules | ||
| - task: AzurePowerShell@5 | ||
| displayName: 'Cleanup deployments via connection [$(serviceConnection)]' | ||
| inputs: | ||
| azureSubscription: '$(serviceConnection)' | ||
| azurePowerShellVersion: 'latestVersion' | ||
| preferredAzurePowerShellVersion: '' | ||
| pwsh: true | ||
| ScriptType: InlineScript | ||
| inline: | | ||
| # Load used functions | ||
| . (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'deploymentRemoval' 'Clear-SubscriptionDeployment.ps1') | ||
|
|
||
| $functionInput = @{ | ||
| SubscriptionId = '$(ARM_SUBSCRIPTION_ID)' | ||
| maxDeploymentRetentionInDays = ${{ parameters.maxDeploymentRetentionInDays }} | ||
| } | ||
|
|
||
| Write-Verbose 'Invoke task with' -Verbose | ||
| Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
|
|
||
| Clear-SubscriptionDeployment @functionInput | ||
|
|
||
| - job: Remove_ManagementGroup_Deployments | ||
| condition: and(succeeded(), eq('${{ parameters.handleManagementGroupScope }}', 'true')) | ||
| displayName: Remove Management Group deployments | ||
| pool: | ||
| ${{ if eq(variables['vmImage'], '') }}: | ||
| name: $(poolName) | ||
| ${{ if eq(variables['poolName'], '') }}: | ||
| vmImage: $(vmImage) | ||
| steps: | ||
| - checkout: self | ||
| - task: PowerShell@2 | ||
| displayName: 'Setup agent for deployment' | ||
| inputs: | ||
| targetType: inline | ||
| pwsh: true | ||
| script: | | ||
| # Load used functions | ||
| . (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'sharedScripts' 'Set-EnvironmentOnAgent.ps1') | ||
|
|
||
| # Define PS modules to install on the runner | ||
| $Modules = @( | ||
| @{ Name = 'Az.Accounts' } | ||
| ) | ||
|
|
||
| # Set agent up | ||
| Set-EnvironmentOnAgent -PSModules $Modules | ||
| - task: AzurePowerShell@5 | ||
| displayName: 'Cleanup deployments via connection [$(serviceConnection)]' | ||
| inputs: | ||
| azureSubscription: '$(serviceConnection)' | ||
| azurePowerShellVersion: 'latestVersion' | ||
| preferredAzurePowerShellVersion: '' | ||
| pwsh: true | ||
| ScriptType: InlineScript | ||
| inline: | | ||
| # Load used functions | ||
| . (Join-Path '$(System.DefaultWorkingDirectory)' 'utilities' 'pipelines' 'deploymentRemoval' 'Clear-ManagementGroupDeployment.ps1') | ||
|
|
||
| $functionInput = @{ | ||
| ManagementGroupId = '$(ARM_MGMTGROUP_ID)' | ||
| maxDeploymentRetentionInDays = ${{ parameters.maxDeploymentRetentionInDays }} | ||
| } | ||
|
|
||
| Write-Verbose 'Invoke task with' -Verbose | ||
| Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose | ||
|
|
||
| Clear-ManagementGroupDeployment @functionInput | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.