forked from YannickRe/azuredevops-buildagents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanagedimage-cleanup-galleryvm.yml
45 lines (41 loc) · 1.39 KB
/
managedimage-cleanup-galleryvm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
parameters:
- name: variable_group
displayName: Variable Group
type: string
default: BuildAgents
- name: gallery_images_to_keep
displayName: Number of image versions to keep in gallery
type: number
default: 2
- name: agent_pool
displayName: Agent Pool
default: 'Host Pool - Image'
type: string
- name: repository_base_path
displayName: Scripts Path
type: string
default: .
jobs:
- job: cleanupobsoletevmrunnerimages
displayName: 'Cleanup obsolete VM Gallery runner images'
pool:
name: ${{ parameters.agent_pool }}
variables:
- group: ${{ parameters.variable_group }}
steps:
- checkout: self
- ${{ if ne(parameters.repository_base_path, '.') }}:
- checkout: ${{ parameters.repository_base_path }}
- task: PowerShell@2
displayName: 'Remove obsolete VM Gallery runner Images'
inputs:
targetType: filePath
filePath: ${{ parameters.repository_base_path }}/scripts/cleanup-gallery-vmimageversion.ps1
arguments: -ClientId $(CLIENT_ID) `
-ClientSecret $(CLIENT_SECRET) `
-SubscriptionId $(AZURE_SUBSCRIPTION) `
-TenantId $(AZURE_TENANT) `
-ResourceGroup $(AZURE_AGENTS_RESOURCE_GROUP) `
-GalleryName $(GALLERY_NAME) `
-GalleryResourceGroup $(GALLERY_RESOURCE_GROUP) `
-GalleryImagesToKeep ${{ parameters.gallery_images_to_keep }}