Update lf-docker-jobs to enforce macro vars
[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     submodule-recursive: true
30     submodule-timeout: 10
31     submodule-disable: false
32
33     #####################
34     # Job Configuration #
35     #####################
36
37     project-type: freestyle
38     node: '{build-node}'
39     disabled: '{disable-job}'
40
41     properties:
42       - lf-infra-properties:
43           build-days-to-keep: '{build-days-to-keep}'
44
45     parameters:
46       - lf-infra-parameters:
47           project: '{project}'
48           branch: '{branch}'
49           stream: '{stream}'
50           lftools-version: '{lftools-version}'
51       - lf-cmake-parameters:
52           build-dir: '{build-dir}'
53           cmake-opts: '{cmake-opts}'
54           install-prefix: '{install-prefix}'
55           make-opts: '{make-opts}'
56
57     wrappers:
58       - lf-infra-wrappers:
59           build-timeout: '{build-timeout}'
60           jenkins-ssh-credential: '{jenkins-ssh-credential}'
61
62     builders:
63       - lf-infra-pre-build
64       - shell: '{pre-build}'
65       - inject:
66           # Switch this to the sonar wrapper when JJB 2.0 is available
67           properties-content: |
68             SONAR_HOST_URL=https://sonarcloud.io
69             SONAR_SCANNER_VERSION={sonar-scanner-version}
70             PROJECT_KEY={sonarcloud-project-key}
71             PROJECT_ORGANIZATION={sonarcloud-organization}
72             API_TOKEN={sonarcloud-api-token}
73       - shell: !include-raw-escape: ../shell/cmake-sonar.sh
74       - lf-provide-maven-settings-cleanup
75
76     publishers:
77       - lf-infra-publish
78
79 - job-template:
80     name: '{project-name}-cmake-sonar'
81     id: gerrit-cmake-sonar
82     concurrent: false
83     <<: *lf_cmake_sonar
84
85     scm:
86       - lf-infra-gerrit-scm:
87           branch: '$GERRIT_BRANCH'
88           jenkins-ssh-credential: '{jenkins-ssh-credential}'
89           git-url: '{git-url}'
90           refspec: '$GERRIT_REFSPEC'
91           submodule-recursive: '{submodule-recursive}'
92           submodule-timeout: '{submodule-timeout}'
93           submodule-disable: '{submodule-disable}'
94           choosing-strategy: gerrit
95
96     triggers:
97       - timed: '{obj:cron}'
98       - gerrit:
99           server-name: '{gerrit-server-name}'
100           trigger-on:
101             - comment-added-contains-event:
102                 comment-contains-value: '^Patch Set\s+\d+:\s+stage-release\s*$'
103           projects:
104             - project-compare-type: 'ANT'
105               project-pattern: '{project}'
106               branches:
107                 - branch-compare-type: 'ANT'
108                   branch-pattern: '**/{branch}'
109
110 - job-template:
111     name: '{project-name}-cmake-sonar'
112     id: github-cmake-sonar
113     concurrent: false
114     <<: *lf_cmake_sonar
115
116     properties:
117       - lf-infra-properties:
118           build-days-to-keep: '{build-days-to-keep}'
119       - github:
120           url: '{github-url}/{github-org}/{project}'
121
122     scm:
123       - lf-infra-github-scm:
124           url: '{git-clone-url}{github-org}/{project}'
125           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
126           branch: '$sha1'
127           submodule-recursive: '{submodule-recursive}'
128           submodule-timeout: '{submodule-timeout}'
129           submodule-disable: '{submodule-disable}'
130           choosing-strategy: default
131           jenkins-ssh-credential: '{jenkins-ssh-credential}'
132
133     triggers:
134       - timed: '{obj:cron}'
135
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 ################
309 # CMAKE VERIFY #
310 ################
311
312 - lf_cmake_verify: &lf_cmake_verify
313     name: lf-cmake-verify
314
315     ######################
316     # Default parameters #
317     ######################
318
319     branch: master
320     build-days-to-keep: 7
321     build-dir: '$WORKSPACE/target'
322     build-timeout: 15
323     cmake-opts: ''
324     disable-job: false
325     git-url: '$GIT_URL/$PROJECT'
326     github-url: 'https://github.com'
327     install-prefix: '$BUILD_DIR/output'
328     make-opts: ''
329     pre-build: ''
330     stream: master
331     submodule-recursive: true
332     submodule-timeout: 10
333     submodule-disable: false
334
335     gerrit_verify_triggers:
336       - patchset-created-event:
337           exclude-drafts: true
338           exclude-trivial-rebase: false
339           exclude-no-code-change: false
340       - draft-published-event
341       - comment-added-contains-event:
342           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
343
344     gerrit_trigger_file_paths:
345       - compare-type: REG_EXP
346         pattern: '.*'
347
348     # github_included_regions MUST match gerrit_trigger_file_paths
349     github_included_regions:
350       - '.*'
351
352     #####################
353     # Job Configuration #
354     #####################
355
356     project-type: freestyle
357     node: '{build-node}'
358     disabled: '{disable-job}'
359
360     properties:
361       - lf-infra-properties:
362           build-days-to-keep: '{build-days-to-keep}'
363
364     parameters:
365       - lf-infra-parameters:
366           project: '{project}'
367           branch: '{branch}'
368           stream: '{stream}'
369       - lf-cmake-parameters:
370           build-dir: '{build-dir}'
371           cmake-opts: '{cmake-opts}'
372           install-prefix: '{install-prefix}'
373           make-opts: '{make-opts}'
374
375     wrappers:
376       - lf-infra-wrappers:
377           build-timeout: '{build-timeout}'
378           jenkins-ssh-credential: '{jenkins-ssh-credential}'
379
380     builders:
381       - shell: '{pre-build}'
382       - shell: !include-raw-escape: ../shell/cmake-build.sh
383
384     publishers:
385       - lf-infra-publish
386
387 - job-template:
388     name: '{project-name}-cmake-verify-{stream}'
389     id: gerrit-cmake-verify
390     concurrent: true
391     <<: *lf_cmake_verify
392
393     scm:
394       - lf-infra-gerrit-scm:
395           branch: '$GERRIT_BRANCH'
396           jenkins-ssh-credential: '{jenkins-ssh-credential}'
397           git-url: '{git-url}'
398           refspec: '$GERRIT_REFSPEC'
399           submodule-recursive: '{submodule-recursive}'
400           submodule-timeout: '{submodule-timeout}'
401           submodule-disable: '{submodule-disable}'
402           choosing-strategy: gerrit
403
404     triggers:
405       - gerrit:
406           server-name: '{gerrit-server-name}'
407           trigger-on: '{obj:gerrit_verify_triggers}'
408           projects:
409             - project-compare-type: 'ANT'
410               project-pattern: '{project}'
411               branches:
412                 - branch-compare-type: 'ANT'
413                   branch-pattern: '**/{branch}'
414               file-paths: '{obj:gerrit_trigger_file_paths}'
415
416 - job-template:
417     name: '{project-name}-cmake-verify-{stream}'
418     id: github-cmake-verify
419     concurrent: true
420     <<: *lf_cmake_verify
421
422     properties:
423       - lf-infra-properties:
424           build-days-to-keep: '{build-days-to-keep}'
425       - github:
426           url: '{github-url}/{github-org}/{project}'
427
428     scm:
429       - lf-infra-github-scm:
430           url: '{git-clone-url}{github-org}/{project}'
431           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
432           branch: '$sha1'
433           submodule-recursive: '{submodule-recursive}'
434           submodule-timeout: '{submodule-timeout}'
435           submodule-disable: '{submodule-disable}'
436           choosing-strategy: default
437           jenkins-ssh-credential: '{jenkins-ssh-credential}'
438
439     triggers:
440       - github-pull-request:
441           trigger-phrase: '^(recheck|reverify)$'
442           only-trigger-phrase: false
443           status-context: 'CMake Verify'
444           permit-all: true
445           github-hooks: true
446           included-regions: '{obj:github_included_regions}'
447           white-list-target-branches:
448             - '{branch}'