-
Notifications
You must be signed in to change notification settings - Fork 67
/
Jenkinsfile
58 lines (57 loc) · 1.17 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
import java.text.SimpleDateFormat
pipeline {
agent {
label "test"
}
options {
buildDiscarder(logRotator(numToKeepStr: "2"))
disableConcurrentBuilds()
}
stages {
stage("checkout") {
steps {
script {
def props = readProperties file: "/run/secrets/cluster-info.properties"
env.HOST_IP = props.hostIp
env.DOCKER_HUB_USER = props.dockerHubUser
}
stash name: "compose", includes: "docker-compose.yml"
}
}
stage("build") {
steps {
dockerBuild("go-demo-2", env.DOCKER_HUB_USER)
}
}
stage("functional") {
steps {
dockerFunctional("go-demo-2", env.DOCKER_HUB_USER, env.HOST_IP, "/demo")
}
}
stage("release") {
when {
branch "master"
}
steps {
dockerRelease("go-demo-2", env.DOCKER_HUB_USER)
}
}
stage("deploy") {
when {
branch "master"
}
agent {
label "prod"
}
steps {
unstash "compose"
dockerDeploy("go-demo-2", env.DOCKER_HUB_USER, env.HOST_IP, "/demo")
}
}
}
post {
always {
dockerCleanup("go-demo-2")
}
}
}