This repository has been archived by the owner on Oct 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
62 lines (54 loc) · 1.56 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
boolean deploy = BRANCH_NAME.contains("hotfix/") || BRANCH_NAME == "master"
boolean integrate = !deploy
boolean publish = BRANCH_NAME.contains("ready/")
println ("----------------")
println "Branch: ${BRANCH_NAME}"
println "integrate: ${integrate}"
println "publish: ${publish}"
println "deploy: ${deploy}"
println ("----------------")
node ('master') {
stage ("Checkout") {
checkout scm
}
if (integrate) {
stage ("Integrate") {
sh "git checkout master"
sh "git merge origin/${BRANCH_NAME}"
}
}
stage ("Build") {
sh "./build.sh"
}
if (publish) {
stage ("Publish") {
// Properly set up ssh keys to avoid this
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: "praqma-thi",
passwordVariable: 'PASSWORD',
usernameVariable: 'USERNAME'
]]) {
sh "git push https://${USERNAME}:${PASSWORD}@github.com/praqma-thi/wf-test.git master"
sh "git push https://${USERNAME}:${PASSWORD}@github.com/praqma-thi/wf-test.git :${BRANCH_NAME}"
}
}
}
}
if (deploy) {
stage('Deploy?'){
try {
timeout(time: 1, unit: 'HOURS') {
input 'Promote? (Remember to tag!)'
}
} catch (Throwable t) {
currentBuild.result = 'SUCCESS'
return
}
}
node ('master') {
stage ("Deploy to test") {
sh "./deploy.sh test-server"
}
}
}