-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
71 lines (64 loc) · 1.9 KB
/
Jenkinsfile
File metadata and controls
71 lines (64 loc) · 1.9 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
pipeline {
agent {
label 'arm64 || amd64'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 60, unit: 'MINUTES')
timestamps()
}
environment {
DOCKER_REGISTRY = 'docker.io'
IMAGE_NAME = 'casjaysdevdocker/couchdb'
DOCKER_BUILDKIT = '1'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build Multi-Arch Image') {
steps {
script {
def buildArgs = ""
if (fileExists('.env.scripts')) {
buildArgs = "--build-arg-file .env.scripts"
}
sh """
docker buildx create --use --name mybuilder || true
docker buildx build \\
--platform linux/amd64,linux/arm64 \\
--tag ${DOCKER_REGISTRY}/${IMAGE_NAME}:latest \\
--tag ${DOCKER_REGISTRY}/${IMAGE_NAME}:\${BUILD_NUMBER} \\
${buildArgs} \\
--push .
"""
}
}
}
stage('Test') {
steps {
script {
sh """
docker run --rm --platform linux/\$(uname -m) \\
${DOCKER_REGISTRY}/${IMAGE_NAME}:latest \\
/bin/sh -c 'echo "Container test passed"'
"""
}
}
}
}
post {
always {
sh 'docker buildx rm mybuilder || true'
cleanWs()
}
success {
echo 'Build completed successfully!'
}
failure {
echo 'Build failed!'
}
}
}