-
Notifications
You must be signed in to change notification settings - Fork 10
/
Jenkinsfile
97 lines (89 loc) · 2.13 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
node {
//
def scmVars
def pullRequest = false
def commitSha
def sourcedBranch
def pullId
def targetBranch
def changes = ''
//
stage('Checkout') {
//
scmVars = checkout scm
//
// Create config for detached build
sh "echo '{\"detach\": true}' > '.tlnrc'"
//
}
try {
//
commitSha = scmVars.GIT_COMMIT
sourcedBranch = scmVars.GIT_BRANCH
if (sourcedBranch.contains('PR-')) {
// multibranch PR build
pullRequest = true
pullId = env.CHANGE_ID
} else if (params.containsKey('sha1')){
// standard PR build
pullRequest = true
sourcedBranch = params.GIT_BRANCH
pullId = params.ghprbPullId
commitSha = params.ghprbActualCommit
targetBranch = params.ghprbTargetBranch
} else {
// PUSH build
}
//
println('SCM variables')
println(scmVars)
println('Job input parameters')
println(params)
println('Build info')
println("[PR:${pullRequest}] [SOURCE BRANCH:${sourcedBranch}] [COMMIT: ${commitSha}] [PULL ID: ${pullId}] [TARGET BRANCH: ${targetBranch}]")
println('Environment variables')
println(sh(script:'env', returnStdout: true))
//
if (pullRequest) {
changes = sh(script:"git diff --name-only HEAD origin/${targetBranch}", returnStdout: true)
}
println('Changes')
println(changes)
stage('Setup build environment') {
sh '''
tln prereq-app
'''
}
stage('Build web/portal') {
if (changes.contains('web/portal') || !pullRequest) {
sh '''
tln init:build:test web/portal
'''
}
}
stage('Build services/auth') {
if (changes.contains('ervices/auth') || !pullRequest) {
sh '''
tln build:test services/auth
'''
}
}
stage('SonarQube analysis') {
}
stage('Delivery') {
if (pullRequest){
} else {
// create docker, push artifacts to the Harbor/Nexus/etc.
// archiveArtifacts artifacts: 'path/2/artifact'
}
}
stage('Deploy') {
if (pullRequest){
} else {
}
}
} catch (e) {
def traceStack = e.toString()
throw e
}
}