-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
42 lines (42 loc) · 1.1 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
pipeline {
environment {
imagename = "jbhome/caddy-authelia"
registryCredential = 'hub.docker.com'
dockerImage = ''
}
agent any
stages {
stage('Building image') {
steps{
sh "chmod +x ./get-version.sh"
sh "./get-version.sh" // Get caddy version and store in version.properties
load "./version.properties"
script {
dockerImage = docker.build("$imagename", "--no-cache .")
}
}
}
stage('Deploy Image') {
steps{
script {
docker.withRegistry( '', registryCredential ) {
dockerImage.push("$CADDY_VERSION")
dockerImage.push("latest")
}
}
sh "docker tag $imagename $imagename:latest"
sh "docker tag $imagename $imagename:$CADDY_VERSION"
}
}
stage('Remove Unused docker image') {
steps{
sh "docker rmi caddy:builder-alpine"
sh "docker rmi caddy:latest"
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS')
{
sh "docker rmi \$(docker images -f dangling=true -q)"
}
}
}
}
}