-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
68 lines (64 loc) · 1.41 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
import static io.aramse.f8.Utils.*
def mainBranches = ["master", "main"]
def mergedBranch
pipeline {
agent any
options {
disableConcurrentBuilds()
}
environment {
COMMIT_HASH = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
F8_TAG = "$BRANCH_NAME-$BUILD_ID-$COMMIT_HASH"
F8_ENVIRONMENT = "$BRANCH_NAME"
F8_ENV_TYPE = "${mainBranches.contains(env.BRANCH_NAME) ? 'prod' : env.BRANCH_NAME}"
F8_LOG_LINKS = "true"
BUILD_CMD = "f8 build --push"
DEPLOY_CMD = "f8 deploy"
TEST_CMD = "f8 test"
}
stages {
stage('Build') {
steps {
script {
mergedBranch = getMergedBranch(this)
if (env.REG_USER != "") {
docker.withRegistry(env.REG_AUTH_URL, env.REG_CREDS_ID) {
sh env.BUILD_CMD
}
} else {
sh env.BUILD_CMD
}
}
}
}
stage('Deploy') {
steps {
sh env.DEPLOY_CMD
}
}
stage('Test') {
steps {
sh env.TEST_CMD
}
}
stage('Delete Merged Env') {
when {
expression {
mainBranches.contains(env.BRANCH_NAME) && mergedBranch
}
}
steps {
sh 'f8 delete --env ' + mergedBranch
}
}
}
post {
always {
script {
if (env.SLACK_ENABLED == 'true') {
slackNotify(this, currentBuild.result)
}
}
}
}
}