-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
93 lines (86 loc) · 2.69 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env groovy
pipeline {
agent any
environment {
VERSION = sh(returnStdout: true, script: 'mvn exec:exec -Dexec.executable=awk -Dexec.args="\'BEGIN {printf(\\"%s-\\", gensub(/-SNAPSHOT/,\\"\\", \\"g\\", \\"\\${project.version}\\"));system(\\"git rev-parse --short=5 HEAD\\")}\'" --non-recursive -q').trim()
}
tools {
maven 'maven3.8.1'
jdk 'JDK1.8'
}
stages {
stage ('Maven Build ') {
when { anyOf { branch 'next'; branch 'develop' } }
steps {
script {
sh '''
mvn clean install -DskipTests
'''
}
}
}
stage('Generate keystore') {
steps {
script {
sh '''
./generateKeyStore-linux.sh
'''
}
}
}
stage ('Push Docker Image to Amazon ECR') {
when { anyOf { branch 'next'; branch 'develop'} }
steps {
script {
echo "Starting to build and push image"
sh '''
mvn jib:build
'''
}
}
}
stage('Deploy to Staging') {
when {
branch 'next'
}
environment {
ENV = 'stg'
}
steps {
script {
echo "Starting to deploy to EKS"
sh '''
envsubst < values-${ENV}.yaml | helm upgrade --install twinci-service-${ENV} --namespace=twinci-${ENV} -f - /var/lib/jenkins/template/twinci-aws-application
'''
}
}
}
stage('Deploy to Production') {
when {
branch 'develop'
}
environment {
ENV = 'prd'
}
steps {
script {
echo "Starting to deploy to EKS"
sh '''
envsubst < values-prd.yaml | helm upgrade --install twinci-service --namespace=twinci -f - /var/lib/jenkins/template/twinci-aws-application
'''
}
}
}
}
post {
success {
slackSend color: "good", message: "SUCCESSFUL: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
}
failure {
slackSend color: "danger", message: "FAILED: ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
}
always {
cleanWs()
}
}
}