-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
50 lines (39 loc) · 1.45 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
node {
properties([
parameters([
string(name: 'pluginName', trim: true, description: pluginNameDescription(), defaultValue: 'none'),
booleanParam(name: 'premiumPlugin', description: "Select this, if the plugin should be handled as a premium plugin")
])
])
stage('Checkout') {
checkout scm
}
stage('Create Job') {
if (env.BRANCH_NAME == 'master') {
currentBuild.description = params.pluginName
jobDsl targets: 'plugin.groovy'
} else {
echo 'skip, executing job dsl in order to avoid bringing an unfinished feature live.'
}
}
stage('Update GitHub') {
if (env.BRANCH_NAME == 'master' && isBuildSuccess()) {
sh 'git checkout master'
// push changes to GitHub
authGit 'cesmarvin', "push -f https://github.com/scm-manager/plugin-seed-job master --tags"
}
}
}
def pluginNameDescription() {
"Name of the plugin. Use 'none' to update the SCM Plugin Jenkinsfile only. Use 'all' to create a job for every plugin in the scm-manager github organization."
}
boolean isBuildSuccess() {
return currentBuild.result == null || currentBuild.result == 'SUCCESS'
}
void authGit(String credentials, String command) {
withCredentials([
usernamePassword(credentialsId: credentials, usernameVariable: 'AUTH_USR', passwordVariable: 'AUTH_PSW')
]) {
sh "git -c credential.helper=\"!f() { echo username='\$AUTH_USR'; echo password='\$AUTH_PSW'; }; f\" ${command}"
}
}