-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSeed.groovy
82 lines (78 loc) · 2.32 KB
/
Seed.groovy
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
def jobs = [
[name: 'Jenkins Setup', repo: '[email protected]:google-cloud-tools/jenkins-setup.git', branch: '*/master', ignoreScm: '.*Seed\\.groovy'],
]
def multibranchJobs = [
[name: 'Jenkins Setup All Branches', repo: '[email protected]:google-cloud-tools/jenkins-setup.git', branch: '*/master', ignoreScm: '.*Seed\\.groovy'],
]
//trigger
jobs.each { i ->
job = pipelineJob(i.name) {
if (i.disabled != null && i.disabled) {
disabled()
}
logRotator() {
artifactNumToKeep(30)
numToKeep(30)
}
definition {
cpsScm {
scm {
git {
remote {
url("${i.repo}")
credentials('jenkins-git-ssh-key')
if(i.refspec != null) {
refspec(i.refspec)
}
}
branch(i.branch)
if (i.ignoreScm != null) {
extensions {
pathRestriction {
includedRegions('')
excludedRegions(i.ignoreScm)
}
}
}
}
if (i.jenkinsfile != null) {
scriptPath(i.jenkinsfile)
} else {
scriptPath('Jenkinsfile')
}
}
}
}
triggers {
if(i.scmtrigger != null) {
scm(i.scmtrigger)
} else {
scm('H/5 * * * *')
}
if (i.upstreams != null) {
upstream(i.upstreams.join(', '), 'SUCCESS')
}
}
if (i.upstreams != null) {
blockOnUpstreamProjects()
}
}
}
multibranchJobs.each { job ->
multibranchPipelineJob(job.name) {
branchSources {
git {
remote("${i.repo}")
excludes('master')
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(0)
}
}
triggers {
periodic(1)
}
}
}