-
Notifications
You must be signed in to change notification settings - Fork 39
/
Jenkinsfile
42 lines (38 loc) · 1.02 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
node {
checkout scm
def config = readYaml(file: "jenkins_job_config.yaml")
def folders = config.folders
def folders_dsls = folders.collect { """
folder('${it.folder_path}') {
description('${it.description}')
}
"""}
def jobs = config.jobs
def jobs_dsls = jobs.collect { """
pipelineJob('${it.job_path}') {
${optionallyTriggerWithGithubHook(it.auto_trigger)}
definition {
cpsScm {
scm {
git('${it.jenkinsfile_git_repo}', "master")
}
scriptPath('${it.jenkinsfile_path}')
}
}
}
"""}
def final_dsl = folders_dsls.join("\n") + "\n" + jobs_dsls.join("\n")
jobDsl removedConfigFilesAction: 'DELETE', removedJobAction: 'DELETE', removedViewAction: 'DELETE', sandbox: true, scriptText: "$final_dsl"
}
def optionallyTriggerWithGithubHook(boolean trigger_required) {
if(trigger_required) {
"""
triggers {
githubPush()
}
"""
}
else {
""
}
}