-
Notifications
You must be signed in to change notification settings - Fork 15
/
Jenkinsfile
77 lines (75 loc) · 2.16 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
pipeline {
environment {
devRegistry = 'ghcr.io/datakaveri/lip-dev'
deplRegistry = 'ghcr.io/datakaveri/lip-depl'
registryUri = 'https://ghcr.io'
registryCredential = 'datakaveri-ghcr'
GIT_HASH = GIT_COMMIT.take(7)
}
agent {
node {
label 'slave1'
}
}
stages {
stage('Build images') {
steps {
script {
devImage = docker.build(devRegistry, "-f vertx/docker/dev.dockerfile vertx/")
deplImage = docker.build(deplRegistry, "-f vertx/docker/depl.dockerfile vertx/")
}
}
}
stage('Continuous Deployment') {
when {
allOf {
anyOf {
changeset "vertx/docker/**"
changeset "vertx/docs/**"
changeset "vertx/pom.xml"
changeset "vertx/src/main/**"
triggeredBy cause: 'UserIdCause'
}
expression {
return env.GIT_BRANCH == 'origin/master';
}
}
}
stages {
stage('Push Images') {
steps {
script {
docker.withRegistry( registryUri, registryCredential ) {
devImage.push("5.6.0-alpha-${env.GIT_HASH}")
deplImage.push("5.6.0-alpha-${env.GIT_HASH}")
}
}
}
}
stage('Docker Swarm deployment') {
steps {
script {
sh "ssh azureuser@docker-swarm 'docker service update lip_lip --image ghcr.io/datakaveri/lip-depl:5.6.0-alpha-${env.GIT_HASH}'"
sh 'sleep 10'
}
}
post {
failure {
error "Failed to deploy image in Docker Swarm"
}
}
}
}
post {
failure {
script {
if (env.GIT_BRANCH == 'origin/master') {
emailext recipientProviders: [buildUser(), developers()], to: '$RS_RECIPIENTS, $DEFAULT_RECIPIENTS', subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!', body: '''$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
Check console output at $BUILD_URL to view the results.'''
}
}
}
}
}
}
}