-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins-job-builder-example-config.yaml
370 lines (348 loc) · 13.5 KB
/
jenkins-job-builder-example-config.yaml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
##############################################################################################################
########## This is an example configuration.
########## It is missing a lot of variables which you should supply yourself in a additional file.
########## This is based on our modified Jenkins-Job-Builder fork, as the mainline does not
########## fully support Jenkins Pipeline and Jenkins Multi-Branch Pipeline job types.
########## For more information, see: https://github.com/abnamrocoesd/jenkins-job-builder
##############################################################################################################
################ D E F A U L T S #########################################################################
- job_bare_defaults: &job_bare_defaults
name: 'defaults'
project-type: freestyle
defaults: global
disabled: false
logrotate:
daysToKeep: 7
numToKeep: 5
artifactDaysToKeep: -1
artifactNumToKeep: -1
jdk: '{default-jdk}'
wrappers:
- timeout:
timeout: 30
timeout-var: 'BUILD_TIMEOUT'
fail: true
type: absolute
- mask-passwords
- build-name:
name: '#${{BUILD_NUMBER}} ${{GIT_BRANCH, fullName=false}}'
publishers:
- email:
notify-every-unstable-build: true
send-to-individuals: true
- job_defaults: &job_defaults
name: 'defaults'
<<: *job_bare_defaults
scm:
- git:
url: '{fed-git-url}/{npmComponentId}.git'
branches:
- '${{branch}}'
local-branch: '${{branch}}'
wipe-workspace: true
credentials-id: '{default-credentials-id}'
ignore-notify: '{ignoreNotify}'
shallow-clone: '{shallowClone}'
git-config-name: 'Jenkins'
git-config-email: '[email protected]'
- job_version_defaults: &job_version_defaults
name: 'defaults'
<<: *job_defaults
parameters:
- choice:
name: semVer
choices:
- prerelease
- major
- minor
- patch
- premajor
- preminor
- prepatch
description: "What part of the version to bump?"
- string:
name: branch
default: ''
description: ''
- bool:
name: deploy
default: false
description: "<h2>Should the documentation be deployed when successful?</h2> <h3>[defaults to 'false']</h3>"
publishers:
- email:
notify-every-unstable-build: true
send-to-individuals: true
- archive:
artifacts: 'version.txt'
fingerprint: true
- git:
push-merge: true
push-only-if-success: true
ignore-notify: '{ignoreNotify}'
branches:
- branch:
remote: origin
name: '${{branch}}'
- workflow_trigger_job_defaults: &workflow_trigger_job_defaults
name: 'defaults'
description: 'Workflow trigger for {npmComponentId}'
<<: *job_bare_defaults
scm:
- git:
url: '{fed-git-url}/{npmComponentId}.git'
credentials-id: '{default-credentials-id}'
builders:
- batch:
!include-raw-escape: workflow-trigger-windows-command.txt
- conditional-step:
condition-kind: not
condition-operand:
condition-kind: strings-match
condition-string1: '${{PROPFILE,file="commitmessage.properties",property="commitmessage"}}'
condition-string2: "'[{jiraProjectCode}]Version updated by CI/CD Pipeline'"
condition-case-insensitive: true
steps:
- trigger-builds:
- project: '{name}-{npmComponentId}-trigger'
current-parameters: true
predefined-parameters: |
GIT_BRANCH=${{GIT_BRANCH}}
flowType=push
push_commit=${{GIT_COMMIT}}
projectWorkflowFolder={name}-{npmComponentId}-workflow
- workflow_job_defaults: &workflow_job_defaults
name: 'defaults'
project-type: workflow
defaults: global
disabled: false
logrotate:
daysToKeep: 7
numToKeep: 5
artifactDaysToKeep: -1
artifactNumToKeep: -1
jdk: '{default-jdk}'
- multibranch_job_defaults: &multibranch_job_defaults
name: 'defaults'
project-type: multibranch
defaults: global
disabled: false
multibranch:
timer-trigger: "@midnight"
periodic-folder-interval: '86400000'
periodic-folder-spec: 'H H * * *'
prune-dead-branches: 'true'
number-to-keep: '10'
days-to-keep: '10'
scm:
git:
url: '{fed-git-url}/{npmComponentId}.git'
credentials-id: '{default-credentials-id}'
publisher-white-list:
- au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger
- com.cloudbees.jenkins.GitHubCommitNotifier
- com.cloudbees.opscenter.triggers.RemoteTriggerPublisher
- com.cloudbees.plugins.deployer.DeployPublisher
- com.michelin.cio.hudson.plugins.copytoslave.CopyToMasterNotifier
- com.sonatype.insight.ci.hudson.PostBuildScan
- com.urbancode.ds.jenkins.plugins.urbandeploypublisher.UrbanDeployPublisher
- hudson.maven.MavenTestDataPublisher
- hudson.maven.RedeployPublisher
- hudson.plugins.analysis.collector.AnalysisPublisher
- hudson.plugins.checkstyle.CheckStylePublisher
- hudson.plugins.descriptionsetter.DescriptionSetterPublisher
- hudson.plugins.findbugs.FindBugsPublisher
- hudson.plugins.git.GitPublisher
- hudson.plugins.jacoco.JacocoPublisher
- hudson.plugins.parameterizedtrigger.BuildTrigger
- hudson.plugins.pmd.PmdPublisher
- hudson.plugins.promoted_builds.KeepBuildForeverAction
- hudson.plugins.promoted_builds.tasks.RedeployBatchTaskPublisher
- hudson.plugins.sonar.SonarPublisher
- hudson.tasks.ArtifactArchiver
- hudson.tasks.BuildTrigger
- hudson.tasks.Fingerprinter
- hudson.tasks.JavadocArchiver
- hudson.tasks.Mailer
- hudson.tasks.junit.JUnitResultArchiver
- hudson.tasks.test.AggregatedTestResultPublisher
- jenkins.plugins.publish_over_cifs.CifsPromotionPublisherPlugin
- jenkins.plugins.publish_over_cifs.CifsPublisherPlugin
- org.jenkins_ci.plugins.flexible_publish.FlexiblePublisher
- org.jenkinsci.plugins.nexus.NexusTaskPublisher
- org.jenkinsci.plugins.stashNotifier.StashNotifier
- stashpullrequestbuilder.stashpullrequestbuilder.StashPostBuildComment
env-properties: |
semVer=prerelease
branchType={defaultBranchType}
flowType=nightly
versionJob={versionJob}
sonarJob={sonarJob}
deployJob={deployJob}
nexusComponentId={nexusComponentId}
nexusRepositoryUrl={nexus-npm-url}
flowFile={flowFile}
flowScm={flow-git-url}/{flowProject}.git
flowBranch={flowGitBranchId}
flowCredentialsId={flow-credentials-id}
componentScm={fed-git-url}/{npmComponentId}.git
componentCredentialsId={default-credentials-id}
notifyScmUrl={scm-base-url}
sitePublishLocation={site-publish-location}
sitePublishCredentialsId={site-publish-credentials-id}
phantomjsZip={phantomjs-zip}
##############################################################################################################
##############################################################################################################
################ J O B T E M P L A T E S ####################################################################
################ FLOW ###################
- job-template:
name: '{name}-{componentName}-workflow'
description: 'Workflow Muilti-Branch Job for {npmComponentId}'
defaultBranchType: 'stable'
<<: *multibranch_job_defaults
################ FLOW TRIGGER #############
- job-template:
name: '{name}-{componentName}-trigger'
description: 'Flow trigger Job for {npmComponentId}'
<<: *workflow_job_defaults
parameters:
- hidden:
name: push_commit
default: 'empty'
- hidden:
name: flowType
default: 'nightly'
- hidden:
name: sourceBranch
default: 'empty'
- hidden:
name: sourceCommitHash
default: 'empty'
- hidden:
name: targetBranch
default: 'empty'
workflow:
script-path: src/main/groovy/com/abnamro/flow/trigger-flow.groovy
scm:
git:
url: '{flow-git-url}/{flowProject}.git'
branches:
- '{flowGitBranchId}'
credentials-id: '{default-credentials-id}'
################ Version ##################
- job-template:
name: '{name}-{componentName}-version'
description: 'Version bump Job for {npmComponentId}'
<<: *job_version_defaults
ignoreNotify: true
shallowClone: false
builders:
- batch:
!include-raw-escape: windows-npm-version-command-alt.txt
################ Sonar ##################
- job-template:
name: '{name}-{componentName}-sonar'
description: 'SonarQube Job for {npmComponentId}'
<<: *job_defaults
ignoreNotify: true
shallowClone: true
parameters:
- string:
name: branch
default: ''
description: ''
builders:
- batch: '{buildCommand}'
- sonar:
sonar-name: '{sonar-name}'
project: sonar.properties
publishers:
- email:
notify-every-unstable-build: true
send-to-individuals: true
- stash:
url: '{scm-base-url}'
username: '{scm-user}'
password: '{scm-password}'
ignore-ssl: true
include-build-number: true
################ PullRequest - Trigger ##################
- job-template:
name: '{name}-{componentName}-pr-trigger'
description: 'Pull Request Trigger Job for {npmComponentId}'
<<: *workflow_trigger_job_defaults
ignoreNotify: true
shallowClone: false
triggers:
- stash-pullrequest-builder:
cron: '* * * * *'
stash-host: '{scm-base-url}'
credentials-id: '{stash-credentials-id}'
project-code: '{scmProjectCode}'
repository-name: '{npmComponentId}'
ci-build-phrases: 'test this please'
check-destination-commit: 'true'
check-mergeable: 'false'
check-not-conflicted: 'false'
only-build-on-comment: 'false'
################ PUSH TRIGGER #############
- job-template:
name: '{name}-{componentName}-push-trigger'
description: 'Push Trigger Job for {npmComponentId}'
<<: *workflow_trigger_job_defaults
ignoreNotify: false
shallowClone: false
triggers:
- pollscm:
cron: "@yearly"
##############################################################################################################
##############################################################################################################
################ J O B G R O U P S ##########################################################################
- job-group:
name: '{name}-standards-and-guidelines'
componentName: '{npmComponentId}'
deployJob: ''
versionJob: '{name}-{npmComponentId}-version'
sonarJob: ''
flowFile: 'fed-standards-and-guidelines'
jobs:
- '{name}-{componentName}-version':
- '{name}-{componentName}-workflow':
- '{name}-{componentName}-trigger':
- '{name}-{componentName}-pr-trigger':
- '{name}-{componentName}-push-trigger':
- job-group:
name: '{name}-oca'
componentName: '{npmComponentId}'
deployJob: ''
versionJob: '{name}-{npmComponentId}-version'
sonarJob: '{name}-{npmComponentId}-sonar'
flowFile: 'oca'
jobs:
- '{name}-{componentName}-workflow':
- '{name}-{componentName}-version':
- '{name}-{componentName}-sonar':
- '{name}-{componentName}-trigger':
- '{name}-{componentName}-pr-trigger':
- '{name}-{componentName}-push-trigger':
##############################################################################################################
##############################################################################################################
################ J O Bs #####################################################################################
- project:
name: fed
jobs:
- '{name}-standards-and-guidelines':
npmComponentId: sandgdemo1
nexusComponentId: fed-standards-and-guidelines
scmProjectCode: fed
jiraProjectCode: SNG-1
phantomjs-zip: phantomjs-2.1.1-windows.zip
buildCommand:
!include-raw: windows-npm-buildcommand-sg.txt
- '{name}-oca':
scmProjectCode: fed
npmComponentId: oca-copy
jiraProjectCode: OCA-1
nexusComponentId: omnichannel-application
phantomjs-zip: phantomjs-1.9.8-windows.zip
buildCommand:
!include-raw: windows-npm-buildcommand-sg.txt