Adjust cmake-sonar template and script
[releng/global-jjb.git] / jjb / lf-c-cpp-jobs.yaml
1 ---
2 ###############
3 # CMAKE Sonar #
4 ###############
5
6 - lf_cmake_sonar: &lf_cmake_sonar
7     name: lf-cmake-sonar
8
9     ######################
10     # Default parameters #
11     ######################
12
13     branch: master
14     build-days-to-keep: 7
15     build-dir: "$WORKSPACE/target"
16     build-timeout: 15
17     cmake-opts: ""
18     cron: "@daily"
19     disable-job: false
20     git-url: "$GIT_URL/$PROJECT"
21     github-url: "https://github.com"
22     install-prefix: "$BUILD_DIR/output"
23     make-opts: ""
24     pre-build: ""
25     sonar-scanner-version: 3.3.0.1492
26     sonarcloud-api-token: ""
27     sonarcloud-organization: ""
28     sonarcloud-project-key: ""
29     stream: master
30     submodule-recursive: true
31     submodule-timeout: 10
32     submodule-disable: false
33
34     #####################
35     # Job Configuration #
36     #####################
37
38     project-type: freestyle
39     node: "{build-node}"
40     disabled: "{disable-job}"
41
42     properties:
43       - lf-infra-properties:
44           build-days-to-keep: "{build-days-to-keep}"
45
46     parameters:
47       - lf-infra-parameters:
48           project: "{project}"
49           branch: "{branch}"
50           stream: "{stream}"
51           lftools-version: "{lftools-version}"
52       - lf-cmake-parameters:
53           build-dir: "{build-dir}"
54           cmake-opts: "{cmake-opts}"
55           install-prefix: "{install-prefix}"
56           make-opts: "{make-opts}"
57
58     wrappers:
59       - lf-infra-wrappers:
60           build-timeout: "{build-timeout}"
61           jenkins-ssh-credential: "{jenkins-ssh-credential}"
62
63     builders:
64       - lf-infra-pre-build
65       - shell: "{pre-build}"
66       - inject:
67           # Switch this to the sonar wrapper when JJB 2.0 is available
68           properties-content: |
69             SONAR_HOST_URL=https://sonarcloud.io
70             SONAR_SCANNER_VERSION={sonar-scanner-version}
71             PROJECT_KEY={sonarcloud-project-key}
72             PROJECT_ORGANIZATION={sonarcloud-organization}
73             API_TOKEN={sonarcloud-api-token}
74       - shell: !include-raw-escape: ../shell/cmake-sonar.sh
75       - lf-provide-maven-settings-cleanup
76
77     publishers:
78       - lf-infra-publish
79
80 - job-template:
81     name: "{project-name}-cmake-sonar"
82     id: gerrit-cmake-sonar
83     concurrent: false
84     <<: *lf_cmake_sonar
85
86     scm:
87       - lf-infra-gerrit-scm:
88           branch: "$GERRIT_BRANCH"
89           jenkins-ssh-credential: "{jenkins-ssh-credential}"
90           git-url: "{git-url}"
91           refspec: "$GERRIT_REFSPEC"
92           submodule-recursive: "{submodule-recursive}"
93           submodule-timeout: "{submodule-timeout}"
94           submodule-disable: "{submodule-disable}"
95           choosing-strategy: gerrit
96
97     triggers:
98       - timed: "{obj:cron}"
99       - gerrit:
100           server-name: "{gerrit-server-name}"
101           trigger-on:
102             - comment-added-contains-event:
103                 comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
104           projects:
105             - project-compare-type: "ANT"
106               project-pattern: "{project}"
107               branches:
108                 - branch-compare-type: "ANT"
109                   branch-pattern: "**/{branch}"
110
111 - job-template:
112     name: "{project-name}-cmake-sonar"
113     id: github-cmake-sonar
114     concurrent: false
115     <<: *lf_cmake_sonar
116
117     properties:
118       - lf-infra-properties:
119           build-days-to-keep: "{build-days-to-keep}"
120       - github:
121           url: "{github-url}/{github-org}/{project}"
122
123     scm:
124       - lf-infra-github-scm:
125           url: "{git-clone-url}{github-org}/{project}"
126           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
127           branch: "$sha1"
128           submodule-recursive: "{submodule-recursive}"
129           submodule-timeout: "{submodule-timeout}"
130           submodule-disable: "{submodule-disable}"
131           choosing-strategy: default
132           jenkins-ssh-credential: "{jenkins-ssh-credential}"
133
134     triggers:
135       - timed: "{obj:cron}"
136
137 ###############
138 # CMAKE STAGE #
139 ###############
140
141 - lf_cmake_stage: &lf_cmake_stage
142     name: lf-cmake-stage
143
144     ######################
145     # Default parameters #
146     ######################
147
148     branch: master
149     build-days-to-keep: 7
150     build-dir: "$WORKSPACE/target"
151     build-timeout: 15
152     cmake-opts: ""
153     cron: "@daily"
154     disable-job: false
155     git-url: "$GIT_URL/$PROJECT"
156     github-url: "https://github.com"
157     install-prefix: "$BUILD_DIR/output"
158     make-opts: ""
159     mvn-global-settings: global-settings
160     pre-build: ""
161     stream: master
162     submodule-recursive: true
163     submodule-timeout: 10
164     submodule-disable: false
165     version: ""
166
167     #####################
168     # Job Configuration #
169     #####################
170
171     project-type: freestyle
172     node: "{build-node}"
173     disabled: "{disable-job}"
174
175     properties:
176       - lf-infra-properties:
177           build-days-to-keep: "{build-days-to-keep}"
178
179     parameters:
180       - lf-infra-parameters:
181           project: "{project}"
182           branch: "{branch}"
183           stream: "{stream}"
184       - lf-cmake-parameters:
185           build-dir: "{build-dir}"
186           cmake-opts: "{cmake-opts}"
187           install-prefix: "{install-prefix}"
188           make-opts: "{make-opts}"
189       - string:
190           name: NEXUS_GROUP_ID
191           default: "{nexus-group-id}"
192           description: "Project Group ID in Nexus to upload to."
193       - string:
194           name: STAGING_PROFILE_ID
195           default: "{staging-profile-id}"
196           description: "Nexus staging profile ID."
197       - string:
198           name: VERSION
199           default: "{version}"
200           description: |
201             (default: '')
202
203             Project version to stage release as. There are 2 methods for
204             using this value:
205
206                 1) Defined explicitly here.
207                 2) Leave this value blank and set /tmp/artifact_version
208
209             Use method 2 in conjunction with 'pre-build' configuration to
210             generate the artifact_version automatically from files in the
211             project's repository. For example with pre-build script:
212
213             #!/bin/bash
214             MAJOR_VERSION="$(grep 'set(OCIO_VERSION_MAJOR' CMakeLists.txt \
215                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
216             MINOR_VERSION="$(grep 'set(OCIO_VERSION_MINOR' CMakeLists.txt \
217                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
218             PATCH_VERSION="$(grep 'set(OCIO_VERSION_PATCH' CMakeLists.txt \
219                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
220             echo "${{MAJOR_VERSION}}.${{MINOR_VERSION}}.${{PATCH_VERSION}}" > /tmp/artifact_version
221
222     wrappers:
223       - lf-infra-wrappers:
224           build-timeout: "{build-timeout}"
225           jenkins-ssh-credential: "{jenkins-ssh-credential}"
226
227     builders:
228       - lf-infra-pre-build
229       - lf-provide-maven-settings:
230           global-settings-file: "{mvn-global-settings}"
231           settings-file: "{mvn-settings}"
232       - lf-infra-create-netrc:
233           server-id: staging
234       - shell: "{pre-build}"
235       - shell: !include-raw-escape: ../shell/cmake-build.sh
236       - shell: !include-raw-escape: ../shell/cmake-stage.sh
237       - lf-provide-maven-settings-cleanup
238
239     publishers:
240       - lf-infra-publish
241
242 - job-template:
243     name: "{project-name}-cmake-stage-{stream}"
244     id: gerrit-cmake-stage
245     concurrent: true
246     <<: *lf_cmake_stage
247
248     scm:
249       - lf-infra-gerrit-scm:
250           branch: "$GERRIT_BRANCH"
251           jenkins-ssh-credential: "{jenkins-ssh-credential}"
252           git-url: "{git-url}"
253           refspec: "$GERRIT_REFSPEC"
254           submodule-recursive: "{submodule-recursive}"
255           submodule-timeout: "{submodule-timeout}"
256           submodule-disable: "{submodule-disable}"
257           choosing-strategy: gerrit
258
259     triggers:
260       - timed: "{obj:cron}"
261       - gerrit:
262           server-name: "{gerrit-server-name}"
263           trigger-on:
264             - comment-added-contains-event:
265                 comment-contains-value: '^Patch Set\s+\d+:\s+stage-release\s*$'
266           projects:
267             - project-compare-type: "ANT"
268               project-pattern: "{project}"
269               branches:
270                 - branch-compare-type: "ANT"
271                   branch-pattern: "**/{branch}"
272
273 - job-template:
274     name: "{project-name}-cmake-stage-{stream}"
275     id: github-cmake-stage
276     concurrent: true
277     <<: *lf_cmake_stage
278
279     properties:
280       - lf-infra-properties:
281           build-days-to-keep: "{build-days-to-keep}"
282       - github:
283           url: "{github-url}/{github-org}/{project}"
284
285     scm:
286       - lf-infra-github-scm:
287           url: "{git-clone-url}{github-org}/{project}"
288           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
289           branch: "$sha1"
290           submodule-recursive: "{submodule-recursive}"
291           submodule-timeout: "{submodule-timeout}"
292           submodule-disable: "{submodule-disable}"
293           choosing-strategy: default
294           jenkins-ssh-credential: "{jenkins-ssh-credential}"
295
296     triggers:
297       - timed: "{obj:cron}"
298       - github-pull-request:
299           trigger-phrase: "^(stage-release)$"
300           only-trigger-phrase: true
301           status-context: "CMake Stage"
302           permit-all: true
303           github-hooks: true
304           white-list-target-branches:
305             - "{branch}"
306
307 ################
308 # CMAKE VERIFY #
309 ################
310
311 - lf_cmake_verify: &lf_cmake_verify
312     name: lf-cmake-verify
313
314     ######################
315     # Default parameters #
316     ######################
317
318     branch: master
319     build-days-to-keep: 7
320     build-dir: "$WORKSPACE/target"
321     build-timeout: 15
322     cmake-opts: ""
323     disable-job: false
324     git-url: "$GIT_URL/$PROJECT"
325     github-url: "https://github.com"
326     install-prefix: "$BUILD_DIR/output"
327     make-opts: ""
328     pre-build: ""
329     stream: master
330     submodule-recursive: true
331     submodule-timeout: 10
332     submodule-disable: false
333
334     gerrit_verify_triggers:
335       - patchset-created-event:
336           exclude-drafts: true
337           exclude-trivial-rebase: false
338           exclude-no-code-change: false
339       - draft-published-event
340       - comment-added-contains-event:
341           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
342
343     gerrit_trigger_file_paths:
344       - compare-type: REG_EXP
345         pattern: ".*"
346
347     # github_included_regions MUST match gerrit_trigger_file_paths
348     github_included_regions:
349       - ".*"
350
351     #####################
352     # Job Configuration #
353     #####################
354
355     project-type: freestyle
356     node: "{build-node}"
357     disabled: "{disable-job}"
358
359     properties:
360       - lf-infra-properties:
361           build-days-to-keep: "{build-days-to-keep}"
362
363     parameters:
364       - lf-infra-parameters:
365           project: "{project}"
366           branch: "{branch}"
367           stream: "{stream}"
368       - lf-cmake-parameters:
369           build-dir: "{build-dir}"
370           cmake-opts: "{cmake-opts}"
371           install-prefix: "{install-prefix}"
372           make-opts: "{make-opts}"
373
374     wrappers:
375       - lf-infra-wrappers:
376           build-timeout: "{build-timeout}"
377           jenkins-ssh-credential: "{jenkins-ssh-credential}"
378
379     builders:
380       - shell: "{pre-build}"
381       - shell: !include-raw-escape: ../shell/cmake-build.sh
382
383     publishers:
384       - lf-infra-publish
385
386 - job-template:
387     name: "{project-name}-cmake-verify-{stream}"
388     id: gerrit-cmake-verify
389     concurrent: true
390     <<: *lf_cmake_verify
391
392     scm:
393       - lf-infra-gerrit-scm:
394           branch: "$GERRIT_BRANCH"
395           jenkins-ssh-credential: "{jenkins-ssh-credential}"
396           git-url: "{git-url}"
397           refspec: "$GERRIT_REFSPEC"
398           submodule-recursive: "{submodule-recursive}"
399           submodule-timeout: "{submodule-timeout}"
400           submodule-disable: "{submodule-disable}"
401           choosing-strategy: gerrit
402
403     triggers:
404       - gerrit:
405           server-name: "{gerrit-server-name}"
406           trigger-on: "{obj:gerrit_verify_triggers}"
407           projects:
408             - project-compare-type: "ANT"
409               project-pattern: "{project}"
410               branches:
411                 - branch-compare-type: "ANT"
412                   branch-pattern: "**/{branch}"
413               file-paths: "{obj:gerrit_trigger_file_paths}"
414
415 - job-template:
416     name: "{project-name}-cmake-verify-{stream}"
417     id: github-cmake-verify
418     concurrent: true
419     <<: *lf_cmake_verify
420
421     properties:
422       - lf-infra-properties:
423           build-days-to-keep: "{build-days-to-keep}"
424       - github:
425           url: "{github-url}/{github-org}/{project}"
426
427     scm:
428       - lf-infra-github-scm:
429           url: "{git-clone-url}{github-org}/{project}"
430           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
431           branch: "$sha1"
432           submodule-recursive: "{submodule-recursive}"
433           submodule-timeout: "{submodule-timeout}"
434           submodule-disable: "{submodule-disable}"
435           choosing-strategy: default
436           jenkins-ssh-credential: "{jenkins-ssh-credential}"
437
438     triggers:
439       - github-pull-request:
440           trigger-phrase: "^(recheck|reverify)$"
441           only-trigger-phrase: false
442           status-context: "CMake Verify"
443           permit-all: true
444           github-hooks: true
445           included-regions: "{obj:github_included_regions}"
446           white-list-target-branches:
447             - "{branch}"