-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbuild-and-push-images.yml
More file actions
166 lines (146 loc) · 7.18 KB
/
build-and-push-images.yml
File metadata and controls
166 lines (146 loc) · 7.18 KB
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
166
resources:
- repo: self
clean: true
variables:
SITECORE_VERSION: "10.1.0"
SITECORE_SHORT_VERSION: "10.1"
stages:
- stage: Build_xGenerator
displayName: "Build xGenerator"
jobs:
- job: Build_xGenerator_Job
strategy:
matrix:
windows2004:
poolName: "docker-2004-agents"
osVersion: "2004"
nanoserverVersion: "2004"
ltsc2019:
poolName: "docker-ltsc2019-agents"
osVersion: "ltsc2019"
nanoserverVersion: "1809"
20H2:
poolName: "docker-20H2-agents"
osVersion: "20H2"
nanoserverVersion: "20H2"
pool:
name: $(poolName)
workspace:
clean: all
steps:
- task: PowerShell@2
displayName: "Build xGenerator Image"
inputs:
targetType: "inline"
script: |
$sitecoreVersion = "$(SITECORE_VERSION)"
az login -u "$(sitecore.container.registry.username)" -p "$(sitecore.container.registry.password)" -t "$(sitecore.container.registry.tenant)"
az acr login -n $(container.registry.short)
$params = @{}
$params.Add("IsolationMode","process")
$params.Add("Registry","$(REGISTRY)")
$params.Add("WindowsVersion","$(osVersion)")
$params.Add("SitecoreVersion","$sitecoreVersion")
./init-ci.ps1 @params
$env:INTERNAL_NUGET_SOURCE_USERNAME="$(INTERNAL_NUGET_SOURCE_USERNAME)"
$env:INTERNAL_NUGET_SOURCE="$(INTERNAL_NUGET_SOURCE)"
$env:INTERNAL_NUGET_SOURCE_PASSWORD="$(INTERNAL_NUGET_SOURCE_PASSWORD)"
docker-compose build
docker-compose push
$env:SITECORE_VERSION = "$(SITECORE_SHORT_VERSION)"
docker-compose build
docker-compose push
- stage: Build_Linux_Images
dependsOn: [Build_xGenerator]
jobs:
- job: Publish_Asset_Images
displayName: "Download and Extract Asset Images"
pool:
name: "docker-20H2-agents"
steps:
- powershell: |
az login -u "$(sitecore.container.registry.username)" -p "$(sitecore.container.registry.password)" -t "$(sitecore.container.registry.tenant)"
az acr login -n $(container.registry.short)
Install-Module powershell-yaml -Force
Import-Module powershell-yaml
$config = docker-compose config | ConvertFrom-Yaml
$image = $config.services.xGenerator.image
docker pull $image
docker container create --name tempWindows $image
if ($LASTEXITCODE -ne 0)
{
throw "Failed to create container"
}
docker container cp tempWindows:/module $(Build.ArtifactStagingDirectory)
docker container rm -f tempWindows
displayName: "Download Windows Assets"
- publish: $(Build.ArtifactStagingDirectory)
displayName: "Publish Artifacts"
artifact: "assets"
- job: Build_Linux_Images
dependsOn: [Publish_Asset_Images]
timeoutInMinutes: 720
displayName: "Build Linux Images"
condition: succeeded('Publish_Asset_Images')
pool:
name: "docker-linux-agents"
steps:
- checkout: self
clean: true
- task: DownloadPipelineArtifact@2
inputs:
path: "$(Build.SourcesDirectory)"
- task: Bash@3
displayName: "Move assets to build folder"
inputs:
targetType: "inline"
script: |
sudo rsync -a $(Build.SourcesDirectory)/assets/* $(Build.SourcesDirectory)/docker/data/
sudo chown AzDevOps:AzDevOps $(Build.SourcesDirectory)/docker/data/ -R
- powershell: |
az login -u "$(sitecore.container.registry.username)" -p "$(sitecore.container.registry.password)" -t "$(sitecore.container.registry.tenant)"
az acr login -n $(container.registry.short)
$params = @{}
$params.Add("IsolationMode","default")
$params.Add("Registry","$(REGISTRY)")
./init-ci.ps1 @params
$env:INTERNAL_NUGET_SOURCE_USERNAME="$(INTERNAL_NUGET_SOURCE_USERNAME)"
$env:INTERNAL_NUGET_SOURCE="$(INTERNAL_NUGET_SOURCE)"
$env:INTERNAL_NUGET_SOURCE_PASSWORD="$(INTERNAL_NUGET_SOURCE_PASSWORD)"
docker-compose -f docker-compose.linux.yml build
docker-compose -f docker-compose.linux.yml push
$env:SITECORE_VERSION = "$(SITECORE_SHORT_VERSION)"
docker-compose -f docker-compose.linux.yml build
docker-compose -f docker-compose.linux.yml push
displayName: "Build Linux Images"
# - stage: Trigger_Harbor_Push
# displayName: "Trigger Harbor Push"
# dependsOn:
# - Docker_Windows
# - Docker_Linux
# condition: and(succeeded('Docker_Windows'), succeeded('Docker_Linux'),or( eq(variables['Build.SourceBranch'], 'refs/heads/develop'), eq(variables['Build.SourceBranch'], 'refs/heads/main')))
# jobs:
# - job: Harbor_Push
# displayName: "Harbor Push"
# steps:
# - task: TriggerBuild@3
# displayName: "Trigger Harbor Push"
# inputs:
# definitionIsInCurrentTeamProject: true
# buildDefinition: "103"
# queueBuildForUserThatTriggeredBuild: true
# ignoreSslCertificateErrors: false
# useSameSourceVersion: false
# useCustomSourceVersion: false
# useSameBranch: false
# branchToUse: "main"
# waitForQueuedBuildsToFinish: false
# storeInEnvironmentVariable: false
# buildParameters: "namespace: demo, groupName: demo, tag: $(GitVersion.SemVer)"
# authenticationMethod: "Personal Access Token"
# password: "$(System.AccessToken)"
# enableBuildInQueueCondition: false
# dependentOnSuccessfulBuildCondition: false
# dependentOnFailedBuildCondition: false
# checkbuildsoncurrentbranch: false
# failTaskIfConditionsAreNotFulfilled: false