-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJenkinsfile
80 lines (78 loc) · 2.84 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
pipeline {
agent any
tools {nodejs "Node"}
/*options {
//disableConcurrentBuilds() //we use the "Lockable Resources plugin" instead, see stage "Deploy"
}*/
environment {
/**
* "$SAPDEPLOY_CREDENTIALS" ==> "USR:PSW"
* "$SAPDEPLOY_CREDENTIALS_USR" ==> Username
* "$SAPDEPLOY_CREDENTIALS_PSW" ==> Password
*/
// Username + password for ZSJENKINS jenkins user on NPL via "Username and Password"
SAPDEPLOY_CREDENTIALS = credentials('ZSJENKINS_USRPWD')
// Both periodic git jobs and gerrit tiggered jobs have o use same lock!
// Use gerrit project name, thus we need to trim the gerrit base url from GIT_URL for periodic jobs
GERRIT_BASE_URL = "ssh://gerrit.my.company.com:29418/"
LOCK_NAME = "foo" // will be filled dynamically in "Deploy" stage
}
stages {
stage('Prepare') {
steps {
sh 'npm install'
//bat 'npm install'
}
}
stage('Validate') {
steps {
sh 'grunt lint'
//bat 'grunt lint'
}
}
stage('Build') {
when {
anyOf {
expression { env.GERRIT_EVENT_TYPE == "change-merged" } // gerrit merge to master
expression { env.GERRIT_EVENT_TYPE == null } // for periodic job w/o gerrit event
}
}
steps {
sh 'grunt build'
//bat 'grunt build'
}
}
/*
stage('Test'){
steps {
sh 'echo "OPA/Qunit skipped on purpose because nothing is available yet."'
}
}
*/
stage('Deploy') {
when {
anyOf {
expression { env.GERRIT_EVENT_TYPE == "change-merged" } // gerrit merge to master
expression { env.GERRIT_EVENT_TYPE == null } // for periodic job w/o gerrit event
}
}
steps {
// calculate the lock name dynamically:
// Must be same for both gerrit and peridoc triggered jobs!
// Example: "sddr/ui5/ssf-docmgr-SapDeployment"
script {
if ( env.GERRIT_EVENT_TYPE == null ) {
LOCK_NAME = env.GIT_URL.split(GERRIT_BASE_URL)[1] + "-SapDeployment"
} else {
LOCK_NAME = env.GERRIT_PROJECT + "-SapDeployment"
}
}
// here the lock is always the gerrit project + appending "-SapDeployment"
lock (LOCK_NAME) {
sh 'grunt nwabap_ui5uploader:NPL'
//bat 'grunt nwabap_ui5uploader:NPL'
}
}
}
}
}