-
Notifications
You must be signed in to change notification settings - Fork 59
/
Jenkinsfile
55 lines (54 loc) · 1.34 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
import java.text.SimpleDateFormat
pipeline {
agent {
label "test"
}
options {
buildDiscarder(logRotator(numToKeepStr: '2'))
}
triggers {
cron('H H * * 0')
}
stages {
stage("init") {
steps {
script {
def dateFormat = new SimpleDateFormat("yy.MM.dd")
currentBuild.displayName = dateFormat.format(new Date()) + "-" + env.BUILD_NUMBER
}
withCredentials([usernamePassword(
credentialsId: "docker",
usernameVariable: "USER",
passwordVariable: "PASS"
)]) {
sh "docker login -u $USER -p $PASS"
}
}
}
stage("jenkins") {
steps {
sh "cd jenkins && docker image build --no-cache -t vfarcic/jenkins ."
sh "docker image tag vfarcic/jenkins vfarcic/jenkins:${currentBuild.displayName}"
sh "docker image push vfarcic/jenkins:${currentBuild.displayName}"
sh "docker image push vfarcic/jenkins"
}
}
stage("compose") {
steps {
sh "cd docker/compose && docker image build --no-cache -t vfarcic/compose ."
sh "docker image push vfarcic/compose"
}
}
}
post {
always {
sh "docker system prune -f"
}
failure {
slackSend(
color: "danger",
message: "${env.JOB_NAME} failed: ${env.RUN_DISPLAY_URL}"
)
}
}
}