-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
88 lines (88 loc) · 3.07 KB
/
Jenkinsfile
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
pipeline {
agent none
options {
buildDiscarder(logRotator(daysToKeepStr: "${30*6}"))
}
environment {
COMPOSE_DOCKER_CLI_BUILD = 1
DOCKER_BUILDKIT = 1
}
triggers { cron(env.BRANCH_NAME ==~ /^main$/ ? 'H H(0-6) 1 * *' : '') }
stages {
stage('Matrix') {
matrix {
axes {
axis {
name 'BUILD'
values 'php73|php74', 'php80|php81', 'php82|php83'
}
axis {
name 'PLATFORM'
values 'linux-amd64', 'linux-arm64'
}
}
environment {
TAG_SUFFIX = "-${PLATFORM}"
}
stages {
stage('Build, Test, Publish') {
agent { label "${PLATFORM}" }
stages {
stage('Build') {
steps {
sh './build.sh'
}
}
stage('Test') {
steps {
sh './test.sh'
}
}
stage('Publish') {
environment {
DOCKER_REGISTRY_CREDS = credentials('docker-registry-credentials')
}
when {
branch 'main'
}
steps {
sh 'echo "$DOCKER_REGISTRY_CREDS_PSW" | docker login --username "$DOCKER_REGISTRY_CREDS_USR" --password-stdin docker.io'
sh 'docker compose config --services | grep -E "${BUILD}" | xargs docker compose push'
}
post {
always {
sh 'docker logout docker.io'
}
}
}
}
post {
always {
sh 'docker compose down -v --rmi local'
cleanWs()
}
}
}
}
}
}
stage('Publish main image') {
agent { label "linux-amd64" }
environment {
DOCKER_REGISTRY_CREDS = credentials('docker-registry-credentials')
}
when {
branch 'main'
}
steps {
sh './manifest-push.sh'
}
post {
always {
sh 'docker logout docker.io'
cleanWs()
}
}
}
}
}