This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Jenkinsfile
52 lines (49 loc) · 1.78 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
def envFileDeploy
def environmentName
def COLOR_MAP = [
'SUCCESS': 'good',
'FAILURE': 'danger',
]
def secretFolder = '~/configs/cardano-explorer-fe'
pipeline {
agent any
stages {
stage('Build') {
steps {
script {
if (env.BRANCH_NAME == 'test') {
envFileDeploy = secretFolder + '/test-fe.env'
environmentName = 'test'
}
if (env.BRANCH_NAME == 'uat') {
envFileDeploy = secretFolder + '/uat-fe.env'
environmentName = 'uat'
}
if (env.BRANCH_NAME == 'main') {
envFileDeploy = secretFolder + '/prod-fe.env'
environmentName = 'prod'
}
}
sh "cp ${envFileDeploy} .env"
sh "docker build -t cardano-explorer-fe ."
}
}
stage('Deliver') {
steps {
sh "docker compose --env-file ${envFileDeploy} -p ${env.BRANCH_NAME} up -d"
sh "docker images -f 'dangling=true' -q --no-trunc | xargs --no-run-if-empty docker rmi &> /dev/null"
}
}
}
post {
always {
script {
Author_ID = sh(script: "git show -s --pretty=%an", returnStdout: true).trim()
Author_Name = sh(script: "git show -s --pretty=%ae", returnStdout: true).trim()
}
slackSend channel: "#build-group-test",
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* ${env.JOB_NAME} build ${env.BUILD_NUMBER} by commit author: ${Author_ID} \n More information at: ${env.BUILD_URL}"
}
}
}