Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / jjb / lf-go-jobs.yaml
1 ##########
2 # Macros #
3 ##########
4
5 - builder:
6     name: lf-go-test
7     builders:
8       - inject:
9           properties-content: "GO_ROOT={go-root}"
10       - shell: !include-raw-escape: ../shell/go-test.sh
11
12 ####################
13 # COMMON FUNCTIONS #
14 ####################
15
16 - _lf_go_common: &lf_go_common
17     name: lf-go-common
18
19     project-type: freestyle
20     node: "{build-node}"
21
22     ######################
23     # Default parameters #
24     ######################
25
26     archive-artifacts: >
27       **/*.log
28       **/hs_err_*.log
29       **/target/**/feature.xml
30       **/target/failsafe-reports/failsafe-summary.xml
31       **/target/surefire-reports/*-output.txt
32     branch: master
33     build-days-to-keep: 7
34     build-timeout: 60
35     disable-job: false
36     git-url: "$GIT_URL/$PROJECT"
37     github-url: "https://github.com"
38     stream: master
39     submodule-recursive: true
40     submodule-timeout: 10
41     submodule-disable: false
42
43     #####################
44     # Job Configuration #
45     #####################
46
47     disabled: "{disable-job}"
48
49     properties:
50       - lf-infra-properties:
51           build-days-to-keep: "{build-days-to-keep}"
52
53     parameters:
54       - lf-infra-parameters:
55           project: "{project}"
56           branch: "{branch}"
57           stream: "{stream}"
58
59     wrappers:
60       - lf-infra-wrappers:
61           build-timeout: "{build-timeout}"
62           jenkins-ssh-credential: "{jenkins-ssh-credential}"
63
64     publishers:
65       - lf-infra-publish
66
67 ###############
68 # Go Snyk CLI #
69 ###############
70
71 - _lf_go_snyk_cli: &lf_go_snyk_cli
72     name: lf-go-snyk_cli
73
74     ######################
75     # Default parameters #
76     ######################
77
78     branch: master
79     build-days-to-keep: 30 # 30 days for troubleshooting purposes
80     build-timeout: 60
81     disable-job: false
82     git-url: "$GIT_URL/$PROJECT"
83     github-url: "https://github.com"
84     java-version: openjdk11
85     mvn-version: mvn35
86     snyk-cli-options: ""
87     snyk-token-credential-id: snyk-token
88     snyk-org-credential-id: snyk-org
89     stream: master
90     submodule-recursive: true
91     submodule-timeout: 10
92     submodule-disable: false
93
94     gerrit_snyk_triggers:
95       - comment-added-contains-event:
96           comment-contains-value: '^Patch Set\s+\d+:\s+run-snyk\s*$'
97
98     parameters:
99       - lf-infra-parameters:
100           project: "{project}"
101           branch: "{branch}"
102           stream: "{stream}"
103       - string:
104           name: SNYK_CLI_OPTIONS
105           default: "{snyk-cli-options}"
106           description: Additional Snyk CLI commands and options
107       - string:
108           name: ARCHIVE_ARTIFACTS
109           default: "{archive-artifacts}"
110           description: Artifacts to archive to the logs server.
111
112     wrappers:
113       - credentials-binding:
114           - text:
115               credential-id: "{snyk-token-credential-id}"
116               variable: SNYK_TOKEN
117           - text:
118               credential-id: "{snyk-org-credential-id}"
119               variable: SNYK_ORG
120
121     #####################
122     # Job Configuration #
123     #####################
124
125     disabled: "{disable-job}"
126
127     builders:
128       - lf-infra-pre-build
129       - lf-update-java-alternatives:
130           java-version: "{java-version}"
131       - lf-go-test:
132           go-root: "{go-root}"
133       - lf-infra-snyk-cli-scanner
134
135 - job-template:
136     name: "{project-name}-go-snyk-cli-{stream}"
137     id: gerrit-go-snyk-cli
138     <<: *lf_go_common
139     # yamllint disable-line rule:key-duplicates
140     <<: *lf_go_snyk_cli
141
142     scm:
143       - lf-infra-gerrit-scm:
144           jenkins-ssh-credential: "{jenkins-ssh-credential}"
145           git-url: "{git-url}"
146           refspec: "$GERRIT_REFSPEC"
147           branch: "$GERRIT_BRANCH"
148           submodule-recursive: "{submodule-recursive}"
149           submodule-timeout: "{submodule-timeout}"
150           submodule-disable: "{submodule-disable}"
151           choosing-strategy: default
152
153     triggers:
154       # Build weekly on Saturdays
155       - timed: "H H * * 6"
156       - gerrit:
157           server-name: "{gerrit-server-name}"
158           trigger-on: "{obj:gerrit_snyk_triggers}"
159           projects:
160             - project-compare-type: ANT
161               project-pattern: "{project}"
162               branches:
163                 - branch-compare-type: ANT
164                   branch-pattern: "**/{branch}"
165           skip-vote:
166             successful: true
167             failed: true
168             unstable: true
169             notbuilt: true
170
171 - job-template:
172     name: "{project-name}-go-snyk-cli-{stream}"
173     id: github-go-snyk-cli
174     <<: *lf_go_common
175     # yamllint disable-line rule:key-duplicates
176     <<: *lf_go_snyk_cli
177
178     properties:
179       - lf-infra-properties:
180           build-days-to-keep: "{build-days-to-keep}"
181       - github:
182           url: "{github-url}/{github-org}/{project}"
183
184     scm:
185       - lf-infra-github-scm:
186           url: "{git-clone-url}{github-org}/{project}"
187           refspec: ""
188           branch: "refs/heads/{branch}"
189           submodule-recursive: "{submodule-recursive}"
190           submodule-timeout: "{submodule-timeout}"
191           submodule-disable: "{submodule-disable}"
192           choosing-strategy: default
193           jenkins-ssh-credential: "{jenkins-ssh-credential}"
194
195     triggers:
196       # Build weekly on Saturdays
197       - timed: "H H * * 6"
198       - github-pull-request:
199           trigger-phrase: "^run-snyk$"
200           only-trigger-phrase: true
201           status-context: "SNYK scan"
202           permit-all: true
203           github-hooks: true
204           org-list:
205             - "{github-org}"
206           white-list: "{obj:github_pr_allowlist}"
207           admin-list: "{obj:github_pr_admin_list}"
208           white-list-target-branches:
209             - "{branch}"
210
211 #############
212 # Go Verify #
213 #############
214
215 - _lf_go_verify: &lf_go_verify
216     name: lf-go-verify
217
218     concurrent: true
219
220     gerrit_verify_triggers:
221       - patchset-created-event:
222           exclude-drafts: true
223           exclude-trivial-rebase: false
224           exclude-no-code-change: false
225       - draft-published-event
226       - comment-added-contains-event:
227           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
228
229     gerrit_trigger_file_paths:
230       - compare-type: REG_EXP
231         pattern: ".*"
232
233     # github_included_regions MUST match gerrit_trigger_file_paths
234     github_included_regions:
235       - ".*"
236
237     builders:
238       - lf-go-test:
239           go-root: "{go-root}"
240
241 - job-template:
242     name: "{project-name}-go-verify-{stream}"
243     id: gerrit-go-verify
244     <<: *lf_go_common
245     # yamllint disable-line rule:key-duplicates
246     <<: *lf_go_verify
247
248     scm:
249       - lf-infra-gerrit-scm:
250           jenkins-ssh-credential: "{jenkins-ssh-credential}"
251           git-url: "{git-url}"
252           refspec: "$GERRIT_REFSPEC"
253           branch: "$GERRIT_BRANCH"
254           submodule-disable: "{submodule-disable}"
255           submodule-recursive: "{submodule-recursive}"
256           submodule-timeout: "{submodule-timeout}"
257           choosing-strategy: gerrit
258
259     triggers:
260       - gerrit:
261           server-name: "{gerrit-server-name}"
262           trigger-on: "{obj:gerrit_verify_triggers}"
263           projects:
264             - project-compare-type: ANT
265               project-pattern: "{project}"
266               branches:
267                 - branch-compare-type: ANT
268                   branch-pattern: "**/{branch}"
269               file-paths: "{obj:gerrit_trigger_file_paths}"
270
271 - job-template:
272     name: "{project-name}-go-verify-{stream}"
273     id: github-go-verify
274     <<: *lf_go_common
275     # yamllint disable-line rule:key-duplicates
276     <<: *lf_go_verify
277
278     properties:
279       - github:
280           url: "{github-url}/{github-org}/{project}"
281
282     scm:
283       - lf-infra-github-scm:
284           url: "{git-clone-url}{github-org}/{project}"
285           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
286           branch: "$sha1"
287           submodule-recursive: "{submodule-recursive}"
288           submodule-timeout: "{submodule-timeout}"
289           submodule-disable: "{submodule-disable}"
290           choosing-strategy: default
291           jenkins-ssh-credential: "{jenkins-ssh-credential}"
292
293     triggers:
294       - github-pull-request:
295           trigger-phrase: "^(recheck|reverify)$"
296           only-trigger-phrase: true
297           status-context: "Go Verify"
298           permit-all: true
299           github-hooks: true
300           org-list:
301             - "{github-org}"
302           white-list: "{obj:github_pr_allowlist}"
303           admin-list: "{obj:github_pr_admin_list}"
304           white-list-target-branches:
305             - "{branch}"