-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
191 lines (167 loc) · 5.34 KB
/
.gitlab-ci.yml
File metadata and controls
191 lines (167 loc) · 5.34 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
variables:
S3CFG: "/root/.s3cfg"
stages:
- build
- publish
default:
# Only the build stage actually requires a `virt` tagged runner, the rest can use `docker`
tags:
- docker
# This job template defines the build for a single OS template
# The rules attached here make sure that templates are only (re)build on changes to their or shared files.
.build_template:
stage: build
tags:
- virt
- packer
artifacts:
paths:
- build_${TEMPLATE_NAME}/
script:
- make build NAME=${TEMPLATE_NAME}
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- .gitlab-ci.yml
- Makefile
- files/**/*
- templates/${TEMPLATE_NAME}.json
- tpl/**/*
- scripts/**/*
# Publish a built template by uploading it to an S3 bucket, the objects are prefixed with the name of the branch/tag
.upload_template:
stage: publish
image: "ubuntu:20.04"
dependencies:
- build:${TEMPLATE_NAME} # Match the exact build job name
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: on_success
script:
- find . -type f
- apt-get update
- apt-get -y install s3cmd curl
- echo "[default]"|tee ${S3CFG} > /dev/null
- echo "access_key = ${OBJECTS_ACCESS_KEY}"|tee -a ${S3CFG} > /dev/null
- echo "secret_key = ${OBJECTS_SECRET_KEY}"|tee -a ${S3CFG} > /dev/null
- echo "host_bucket = %(bucket)s.${OBJECTS_HOST}"|tee -a ${S3CFG} > /dev/null
- echo "host_base = ${OBJECTS_HOST}"|tee -a ${S3CFG} > /dev/null
- echo "use_https = False"|tee -a ${S3CFG} > /dev/null
- s3cmd -c ${S3CFG} put -P --no-preserve build_${TEMPLATE_NAME}/${TEMPLATE_NAME}.json s3://${OBJECTS_BUCKET}/templates/${TEMPLATE_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}.json
- s3cmd -c ${S3CFG} put -P --no-preserve build_${TEMPLATE_NAME}/${TEMPLATE_NAME}.checksum s3://${OBJECTS_BUCKET}/templates/${TEMPLATE_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}.checksum
- s3cmd -c ${S3CFG} put -P --no-preserve build_${TEMPLATE_NAME}/${TEMPLATE_NAME}.qcow2 s3://${OBJECTS_BUCKET}/templates/${TEMPLATE_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}.qcow2
- sleep 5
- curl -I http://${OBJECTS_BUCKET}.${OBJECTS_HOST}/templates/${TEMPLATE_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}.checksum
- curl -I http://${OBJECTS_BUCKET}.${OBJECTS_HOST}/templates/${TEMPLATE_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}.json
- curl -I http://${OBJECTS_BUCKET}.${OBJECTS_HOST}/templates/${TEMPLATE_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHORT_SHA}.qcow2
# AlmaLinux 8
build:almalinux-8:
extends: .build_template
variables:
TEMPLATE_NAME: "almalinux-8"
publish:almalinux-8:
extends: .upload_template
dependencies:
- build:almalinux-8
variables:
TEMPLATE_NAME: "almalinux-8"
# AlmaLinux 9
build:almalinux-9:
extends: .build_template
variables:
TEMPLATE_NAME: "almalinux-9"
publish:almalinux-9:
extends: .upload_template
dependencies:
- build:almalinux-9
variables:
TEMPLATE_NAME: "almalinux-9"
# AlmaLinux 10
build:almalinux-10:
extends: .build_template
variables:
TEMPLATE_NAME: "almalinux-10"
publish:almalinux-10:
extends: .upload_template
dependencies:
- build:almalinux-10
variables:
TEMPLATE_NAME: "almalinux-10"
# CloudLinux 8
build:cloudlinux-8:
extends: .build_template
variables:
TEMPLATE_NAME: "cloudlinux-8"
publish:cloudlinux-8:
extends: .upload_template
dependencies:
- build:cloudlinux-8
variables:
TEMPLATE_NAME: "cloudlinux-8"
# CloudLinux 9
build:cloudlinux-9:
extends: .build_template
variables:
TEMPLATE_NAME: "cloudlinux-9"
publish:cloudlinux-9:
extends: .upload_template
dependencies:
- build:cloudlinux-9
variables:
TEMPLATE_NAME: "cloudlinux-9"
## Debian 11
build:debian-11:
extends: .build_template
variables:
TEMPLATE_NAME: "debian-11"
publish:debian-11:
extends: .upload_template
dependencies:
- build:debian-11
variables:
TEMPLATE_NAME: "debian-11"
## Debian 12
build:debian-12:
extends: .build_template
variables:
TEMPLATE_NAME: "debian-12"
publish:debian-12:
extends: .upload_template
dependencies:
- build:debian-12
variables:
TEMPLATE_NAME: "debian-12"
## Ubuntu 20.04
build:ubuntu-20.04:
extends: .build_template
variables:
TEMPLATE_NAME: "ubuntu-20.04"
publish:ubuntu-20.04:
extends: .upload_template
dependencies:
- build:ubuntu-20.04
variables:
TEMPLATE_NAME: "ubuntu-20.04"
## Ubuntu 22.04
build:ubuntu-22.04:
extends: .build_template
variables:
TEMPLATE_NAME: "ubuntu-22.04"
publish:ubuntu-22.04:
extends: .upload_template
dependencies:
- build:ubuntu-22.04
variables:
TEMPLATE_NAME: "ubuntu-22.04"
## Ubuntu 24.04
build:ubuntu-24.04:
extends: .build_template
variables:
TEMPLATE_NAME: "ubuntu-24.04"
publish:ubuntu-24.04:
extends: .upload_template
dependencies:
- build:ubuntu-24.04
variables:
TEMPLATE_NAME: "ubuntu-24.04"