-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
75 lines (75 loc) · 2.63 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
pipeline{
agent{
node {
label 'master'
customWorkspace "workspace/${env.BRANCH_NAME}/src/github.com/aditya37/geospatial-tracking"
}
}
environment {
SERVICE = "geospatial-tracking"
NOTIFDEPLOY = -522638644
}
options {
buildDiscarder(logRotator(daysToKeepStr: env.BRANCH_NAME == 'main' ? '90' : '30'))
}
stages{
stage("Checkout"){
when {
anyOf { branch 'main'; branch 'develop'; branch 'staging'}
}
// Do clone
steps {
echo 'Checking out from git'
checkout scm
script {
env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout:true).trim()
}
}
}
stage('Build and deploy') {
environment {
GOPATH = "${env.JENKINS_HOME}/workspace/${env.BRANCH_NAME}"
PATH = "${env.GOPATH}/bin:${env.PATH}"
}
stages {
// build to dev
stage('Deploy to env development') {
when {
branch 'develop'
}
environment {
NAMESPACE = 'geospatial-development'
TAG= '0.0.0'
}
steps {
// get credential file
withCredentials([
file(credentialsId: '8a0b10f8-0ccf-4d2d-9a01-c5881c57237f', variable: 'config'),
file(credentialsId: '9b6787aa-ef79-4c7a-9e7c-f5be36eb606b',variable:'firebasesa')
]) {
echo 'Build image'
sh "cp $config .env.geospatial.tracking"
sh "chmod 644 .env.geospatial.tracking"
sh "cp $firebasesa sa.fbs.device.service.json"
sh 'chmod 644 sa.fbs.device.service.json'
sh 'chmod +x build.sh'
sh './build.sh'
sh 'chmod +x deploy.sh'
sh './deploy.sh'
sh 'rm .env.geospatial.tracking'
sh 'rm sa.fbs.device.service.json'
}
}
}
}
}
}
post{
success{
telegramSend(message:"Application $SERVICE has been [deployed] With Commit Message $GIT_COMMIT_MSG",chatId:"$NOTIFDEPLOY")
}
failure{
telegramSend(message:"Application $SERVICE has been [Failed] With Commit Message $GIT_COMMIT_MSG",chatId:"$NOTIFDEPLOY")
}
}
}