-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
62 lines (62 loc) · 1.98 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
pipeline{
agent{
node {
label 'master'
customWorkspace "workspace/${env.BRANCH_NAME}/src/github.com/aditya37/file-service/"
}
}
environment {
SERVICE = "file-service"
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
}
}
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 = 'core-development'
}
steps {
// get credential file
withCredentials([file(credentialsId: 'b067d4c8-d147-4732-8725-cb84c520759b', variable: 'sa')]) {
echo 'Build image'
sh "cp $sa firebase-admin-key.json"
sh "chmod 644 firebase-admin-key.json"
sh 'chmod +x build.sh'
sh './build.sh default'
}
}
}
}
}
}
post{
success{
telegramSend(message:"Application $SERVICE has been [deployed]",chatId:"$NOTIFDEPLOY")
}
failure{
telegramSend(message:"Application $SERVICE has been [Failed]",chatId:"$NOTIFDEPLOY")
}
}
}