-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
50 lines (50 loc) · 1.36 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
pipeline {
agent {
label 'linux-amd64'
}
options {
buildDiscarder(logRotator(daysToKeepStr: '30'))
}
triggers { cron(env.BRANCH_NAME ==~ /^main$/ ? 'H H(0-6) 1 * *' : '') }
environment {
BUILDKIT_PROGRESS = 'plain'
}
stages {
stage('Setup') {
steps {
script {
env.CONTEXT = sh(script: 'docker buildx create', returnStdout: true).trim()
}
}
}
stage('Build') {
steps {
sh 'docker buildx bake --builder "${CONTEXT}"'
}
}
stage('Publish') {
environment {
DOCKER_REGISTRY_CREDS = credentials('docker-registry-credentials')
DOCKER_REGISTRY = 'quay.io'
}
when {
branch 'main'
}
steps {
sh 'echo "$DOCKER_REGISTRY_CREDS_PSW" | docker login --username "$DOCKER_REGISTRY_CREDS_USR" --password-stdin "$DOCKER_REGISTRY"'
sh 'docker buildx bake --builder "${CONTEXT}" --push'
}
post {
always {
sh 'docker logout "$DOCKER_REGISTRY"'
}
}
}
}
post {
always {
sh 'docker buildx rm "${CONTEXT}"'
cleanWs()
}
}
}