-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
68 lines (63 loc) · 2.07 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
def COLOR_MAP = ['SUCCESS': 'good', 'FAILURE': 'danger', 'UNSTABLE': 'danger', 'ABORTED': 'danger']
pipeline {
agent any
options { disableConcurrentBuilds() }
environment {
TAG = "${BRANCH_NAME}-${BUILD_NUMBER}".toLowerCase().replace("@", "")
TAG_INIT = "${TAG}-init"
TAG_BUILD = "${TAG}-build"
TAG_TEST = "${TAG}-test"
TAG_TEST_STATIC = "${TAG_TEST}-static"
}
stages {
stage('Init') {
steps {
echo 'Init..'
slackSend (color: '#F0E68C', message: "*STARTED:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}")
sh 'docker build --target init -t $TAG_INIT -f Dockerfile.ci .'
}
}
stage('QA: static code analysis') {
steps {
echo 'Testing static..'
sh 'docker build --target test-static -t $TAG_TEST_STATIC -f Dockerfile.ci .'
}
}
stage('QA: unit tests') {
steps {
echo 'Testing..'
sh 'docker build --target test -t $TAG_TEST -f Dockerfile.ci .'
}
}
stage('Build') {
steps {
echo 'Building..'
sh 'docker build --target build -t $TAG_BUILD -f Dockerfile.ci .'
}
}
stage('Deploy') {
when { branch 'master' }
environment {
EXPRESS_SESSION_KEY = credentials('EXPRESS_SESSION_KEY')
GOOGLE_API_USER = credentials('GOOGLE_API_USER')
GOOGLE_CALLBACK_URL = credentials('GOOGLE_CALLBACK_URL')
GOOGLE_CLIENT_ID = credentials('GOOGLE_CLIENT_ID')
GOOGLE_CLIENT_SECRET = credentials('GOOGLE_CLIENT_SECRET')
GOOGLE_REFRESH_TOKEN = credentials('GOOGLE_REFRESH_TOKEN')
HOST = credentials('HOST')
SENDGRID_API_KEY = credentials('SENDGRID_API_KEY')
}
steps {
echo 'Deploying....'
sh 'docker-compose build'
sh 'docker-compose stop'
sh 'docker-compose up -d'
}
}
}
post {
always {
slackSend (color: COLOR_MAP[currentBuild.currentResult], message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER}\n More info at: ${env.BUILD_URL}")
}
}
}