14
14
def buildAgentName (String jobNameWithNamespace , String buildNumber , String namespace ) {
15
15
def jobName = removeNamespaceFromJobName(jobNameWithNamespace, namespace);
16
16
17
- if (jobName. length() > 55 ) {
18
- jobName = jobName. substring(0 , 55 );
17
+ if (jobName. length() > 52 ) {
18
+ jobName = jobName. substring(0 , 52 );
19
19
}
20
20
21
21
return " a.${ jobName}${ buildNumber} " . replace(' _' , ' -' ). replace(' /' , ' -' ). replace(' -.' , ' .' );
@@ -46,6 +46,9 @@ apiVersion: v1
46
46
kind: Pod
47
47
spec:
48
48
serviceAccountName: jenkins
49
+ volumes:
50
+ - emptyDir: {}
51
+ name: varlibcontainers
49
52
containers:
50
53
- name: node
51
54
image: node:12-stretch
77
80
secretKeyRef:
78
81
name: ${ secretName}
79
82
key: password
83
+ - name: buildah
84
+ image: quay.io/buildah/stable:v1.9.2
85
+ tty: true
86
+ command: ["/bin/bash"]
87
+ workingDir: ${ workingDir}
88
+ securityContext:
89
+ privileged: true
90
+ envFrom:
91
+ - configMapRef:
92
+ name: ibmcloud-config
93
+ - secretRef:
94
+ name: ibmcloud-apikey
95
+ env:
96
+ - name: HOME
97
+ value: /home/devops
98
+ - name: ENVIRONMENT_NAME
99
+ value: ${ env.NAMESPACE}
100
+ - name: DOCKERFILE
101
+ value: ./Dockerfile
102
+ - name: CONTEXT
103
+ value: .
104
+ - name: TLSVERIFY
105
+ value: "false"
106
+ - name: REGISTRY_USER
107
+ valueFrom:
108
+ secretKeyRef:
109
+ key: REGISTRY_USER
110
+ name: ibmcloud-apikey
111
+ optional: true
112
+ - name: REGISTRY_PASSWORD
113
+ valueFrom:
114
+ secretKeyRef:
115
+ key: REGISTRY_PASSWORD
116
+ name: ibmcloud-apikey
117
+ optional: true
118
+ - name: APIKEY
119
+ valueFrom:
120
+ secretKeyRef:
121
+ key: APIKEY
122
+ name: ibmcloud-apikey
123
+ optional: true
124
+ volumeMounts:
125
+ - mountPath: /var/lib/containers
126
+ name: varlibcontainers
80
127
- name: ibmcloud
81
- image: docker.io/garagecatalyst/ibmcloud-dev:1.0.8
128
+ image: docker.io/garagecatalyst/ibmcloud-dev:1.0.10
82
129
tty: true
83
130
command: ["/bin/bash"]
84
131
workingDir: ${ workingDir}
@@ -105,7 +152,7 @@ spec:
105
152
- name: ENVIRONMENT_NAME
106
153
value: ${ env.NAMESPACE}
107
154
- name: trigger-cd
108
- image: docker.io/garagecatalyst/ibmcloud-dev:1.0.8
155
+ image: docker.io/garagecatalyst/ibmcloud-dev:1.0.10
109
156
tty: true
110
157
command: ["/bin/bash"]
111
158
workingDir: ${ workingDir}
@@ -175,27 +222,44 @@ spec:
175
222
PRE_RELEASE="--preRelease=${BRANCH}"
176
223
fi
177
224
178
- release-it patch --ci --no-npm ${PRE_RELEASE} \
179
- --hooks.after:release='echo "IMAGE_VERSION=${version}" > ./env-config; echo "IMAGE_NAME=$(echo ${repo.project} | tr '[:upper:]' '[:lower:]')" >> ./env-config' \
180
- --verbose
225
+ release-it patch ${PRE_RELEASE} \
226
+ --ci \
227
+ --no-npm \
228
+ --no-git.requireCleanWorkingDir \
229
+ --verbose \
230
+ -VV
231
+
232
+ echo "IMAGE_VERSION=$(git describe --abbrev=0 --tags)" > ./env-config
233
+ echo "IMAGE_NAME=$(basename -s .git `git config --get remote.origin.url` | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')" >> ./env-config
181
234
182
235
cat ./env-config
183
236
'''
184
237
}
185
238
}
186
- container(name : ' ibmcloud ' , shell : ' /bin/bash' ) {
239
+ container(name : ' buildah ' , shell : ' /bin/bash' ) {
187
240
stage(' Build image' ) {
188
241
sh ''' #!/bin/bash
189
-
242
+ set -e
190
243
. ./env-config
191
244
192
- set +x
245
+ echo TLSVERIFY=${TLSVERIFY}
246
+ echo CONTEXT=${CONTEXT}
247
+
248
+ if [[ -z "${REGISTRY_PASSWORD}" ]]; then
249
+ REGISTRY_PASSWORD="${APIKEY}"
250
+ fi
193
251
194
- echo -e "=========================================================================================="
195
- echo -e "BUILDING CONTAINER IMAGE: ${REGISTRY_URL}/${REGISTRY_NAMESPACE}/${IMAGE_NAME}:${IMAGE_VERSION}"
196
- ibmcloud cr build -t ${REGISTRY_URL}/${REGISTRY_NAMESPACE}/${IMAGE_NAME}:${IMAGE_VERSION} .
252
+ APP_IMAGE="${REGISTRY_URL}/${REGISTRY_NAMESPACE}/${IMAGE_NAME}:${IMAGE_VERSION}"
253
+
254
+ buildah bud --tls-verify=${TLSVERIFY} --format=docker -f ${DOCKERFILE} -t ${APP_IMAGE} ${CONTEXT}
255
+ if [[ -n "${REGISTRY_USER}" ]] && [[ -n "${REGISTRY_PASSWORD}" ]]; then
256
+ buildah login -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}" "${REGISTRY_URL}"
257
+ fi
258
+ buildah push --tls-verify=${TLSVERIFY} "${APP_IMAGE}" "docker://${APP_IMAGE}"
197
259
'''
198
260
}
261
+ }
262
+ container(name : ' ibmcloud' , shell : ' /bin/bash' ) {
199
263
stage(' Deploy to DEV env' ) {
200
264
sh ''' #!/bin/bash
201
265
echo "Deploying to ${ENVIRONMENT_NAME}"
@@ -285,7 +349,7 @@ spec:
285
349
stage(' Package Helm Chart' ) {
286
350
sh ''' #!/bin/bash
287
351
288
- if [[ -z "${ARTIFACTORY_ENCRYPT }" ]]; then
352
+ if [[ -z "${ARTIFACTORY_URL }" ]]; then
289
353
echo "Skipping Artifactory step as Artifactory is not installed or configured"
290
354
exit 0
291
355
fi
0 commit comments