forked from Sitecore/docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-images.yml
165 lines (155 loc) · 6.71 KB
/
build-images.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# The following variables need to be set in Azure Devops:
# Azure
# - azure.subscription
# - azure.agentPoolName
# - azure.vm.resourceGroupName
# - (optional) azure.vm.linux.name
# - azure.vm.windows.name
#
# Image build options
# - build.tags
# - build.pushMode
# - build.pruneImages
# - build.sitecoreVersion
# - build.sitecoreTopology
# - build.sitecoreWindowsVersion
# - build.includeSpe
# - build.includeSxa
# - build.includeJss
# - build.skipExistingImages
# - build.includeExperimentalImages
# Sitecore credentials
# - sitecore.username
# - sitecore.password
#
# Container registry
# - container.registry.password
# - container.registry.username
# - container.registry.fullname
#
# Windows:
# - windows.install.source.path
#
# Assets drive
# - assets.useDrive
# - (optional) assets.azure.fileshare.password
# - (optional) assets.shared.folder.server
#
# Linux
# - linux.buildImages
# - (optional) linux.install.source.path
trigger:
batch: true
branches:
include:
- master
schedules:
- cron: "0 12 * * 0"
displayName: Weekly Sunday build
branches:
include:
- master
always: true
stages:
- stage: Build_Wndows_Images
jobs:
- job: Build_Windows_Images
timeoutInMinutes: 720
displayName: "Build Windows Images"
pool:
name: $(azure.agentPoolName)
steps:
- powershell: |
Test-NetConnection -ComputerName "$(assets.shared.folder.server)" -Port 445
Invoke-Expression -Command "cmdkey /add:$(assets.shared.folder.server) /user:Azure\dockerassets /pass:$(assets.azure.fileshare.password)"
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\$(assets.shared.folder.server)\docker-assets" -Persist -ErrorAction SilentlyContinue
condition: eq(variables['assets.useDrive'], 'true')
displayName: "Connect Asset Drive (optional)"
- task: Docker@2
displayName: "Docker registry login"
inputs:
containerRegistry: "docker-registry"
command: login
- checkout: self
clean: true
- powershell: |
"$(container.registry.password)" | docker login -u "$(container.registry.username)" --password-stdin $(container.registry.fullname)
$buildProps = @{
InstallSourcePath = "$(windows.install.source.path)"
SitecoreUsername = "$(sitecore.username)"
SitecorePassword = "$(sitecore.password)"
Registry = "$(container.registry.fullname)"
RegistryUserName = "$(container.registry.username)"
RegistryPassword = "$(container.registry.password)"
SitecoreVersion = "$(build.sitecoreVersion)"
Topology = $(build.sitecoreTopology)
OSVersion = "$(build.WindowsOSVersion)"
IncludeSpe = [System.Convert]::ToBoolean($(build.includeSpe))
IncludeSxa = [System.Convert]::ToBoolean($(build.includeSxa))
IncludeJss = [System.Convert]::ToBoolean($(build.includeJss))
IncludeExperimental = [System.Convert]::ToBoolean($(build.includeExperimentalImages))
SkipExistingImage = [System.Convert]::ToBoolean($(build.skipExistingImages))
}
.\Build.ps1 @buildProps
displayName: "Build Images"
- powershell: |
docker image prune --force
condition: and(succeeded(), eq(variables['build.pruneImages'], 'true'))
displayName: 'Prune images (optional)'
- job: Build_Linux_Images
timeoutInMinutes: 720
displayName: "Build Linux Images"
condition: eq(variables['build.linuxImages'], 'true')
pool:
vmImage: 'ubuntu-18.04'
steps:
- task: Bash@3
condition: eq(variables['assets.useDrive'], 'true')
inputs:
targetType: inline
script: |
if [ -d "$(linux.install.source.path)" ]; then
exit 0
fi
sudo mkdir $(linux.install.source.path)
if [ ! -d "/etc/smbcredentials" ]; then
sudo mkdir /etc/smbcredentials
fi
if [ ! -f "/etc/smbcredentials/dockerassets.cred" ]; then
sudo bash -c 'echo "username=dockerassets" >> /etc/smbcredentials/dockerassets.cred'
sudo bash -c 'echo "password=$(assets.azure.fileshare.password)" >> /etc/smbcredentials/dockerassets.cred'
fi
sudo chmod 600 /etc/smbcredentials/dockerassets.cred
sudo bash -c 'echo "//$(assets.shared.folder.server)/docker-assets $(linux.install.source.path) cifs nofail,vers=3.0,credentials=/etc/smbcredentials/dockerassets.cred,dir_mode=0777,file_mode=0777,serverino" >> /etc/fstab'
sudo mount -t cifs //$(assets.shared.folder.server)/docker-assets $(linux.install.source.path) -o vers=3.0,credentials=/etc/smbcredentials/dockerassets.cred,dir_mode=0777,file_mode=0777,serverino
- task: Docker@2
enabled: true
displayName: "Docker registry login"
inputs:
containerRegistry: "docker-registry"
command: login
- checkout: self
clean: true
- powershell: |
"$(container.registry.password)" | docker login -u "$(container.registry.username)" --password-stdin $(container.registry.fullname)
$buildProps = @{
InstallSourcePath = "$(linux.install.source.path)"
SitecoreUsername = "$(sitecore.username)"
SitecorePassword = "$(sitecore.password)"
Registry = "$(container.registry.fullname)"
RegistryUserName = "$(container.registry.username)"
RegistryPassword = "$(container.registry.password)"
SitecoreVersion = "$(build.sitecoreVersion)"
Topology = $(build.sitecoreTopology)
OSVersion = "linux"
IncludeSpe = [System.Convert]::ToBoolean($(build.includeSpe))
IncludeSxa = [System.Convert]::ToBoolean($(build.includeSxa))
IncludeJss = [System.Convert]::ToBoolean($(build.includeJss))
IncludeExperimental = [System.Convert]::ToBoolean($(build.includeExperimentalImages))
SkipExistingImage = [System.Convert]::ToBoolean($(build.skipExistingImages))
}
.\Build.ps1 @buildProps
displayName: "Build Linux Images"
- powershell: |
docker image prune --force
condition: and(succeeded(), eq(variables['build.pruneImages'], 'true'))