Allow git-url to be overridden by job
[releng/global-jjb.git] / jjb / lf-ci-jobs.yaml
1 ---
2 - job-group:
3     name: '{project-name}-ci-jobs'
4
5     # This job group contains all the recommended jobs that should be deployed
6     # for any project ci.
7
8     jjb-version: 1.6.2
9
10     jobs:
11       - gerrit-jjb-merge
12       - gerrit-jjb-verify
13
14 - job-group:
15     name: '{project-name}-github-ci-jobs'
16
17     # This job group contains all the recommended jobs that should be deployed
18     # for any project ci that is using github.
19
20     jjb-version: 1.6.2
21
22     jobs:
23       - 'github-jjb-merge'
24       - 'github-jjb-verify'
25
26
27 ####################
28 # Anchors & Macros #
29 ####################
30
31 - builder:
32     name: lf-infra-jjbini
33     builders:
34       - config-file-provider:
35           files:
36             - file-id: jjbini
37               target: '$HOME/.config/jenkins_jobs/jenkins_jobs.ini'
38
39 - lf_jjb_file_paths: &lf_jjb_file_paths
40     name: lf-jjb-file-paths
41     file-paths:
42       - compare-type: ANT
43         pattern: '**/*.sh'
44       - compare-type: ANT
45         pattern: '**/*.yaml'
46
47 - lf_jjb_merge_builders: &lf_jjb_merge_builders
48     name: lf-jjb-merge-builders
49     builders:
50       - lf-infra-jjbini
51       - shell: !include-raw-escape:
52           - ../shell/jjb-install.sh
53           - ../shell/jjb-merge-job.sh
54
55 - lf_jjb_verify_builders: &lf_jjb_verify_builders
56     name: lf-jjb-verfy-builders
57     builders:
58       - lf-infra-jjbini
59       - shell: !include-raw-escape:
60           - ../shell/jjb-install.sh
61           - ../shell/jjb-verify-job.sh
62           - ../shell/jjb-check-unicode.sh
63       - lf-infra-gpg-verify-git-signature
64
65 - parameter:
66     name: lf-infra-jjb-parameters
67     parameters:
68       - string:
69           name: JJB_VERSION
70           default: '{jjb-version}'
71           description: Jenkins Job Builder version to download and install.
72
73 #################
74 # Job Templates #
75 #################
76
77 # JJB verify and merge jobs are the same except for their scm, trigger, and
78 # builders definition. This anchor is the common template
79 - lf_jjb_verify_merge: &lf_jjb_verify_merge
80     name: lf-jjb-verify-merge
81     project-type: freestyle
82
83     node: '{build-node}'
84
85     ######################
86     # Default parameters #
87     ######################
88
89     branch: master
90     submodule-recursive: true
91
92     #####################
93     # Job Configuration #
94     #####################
95
96     properties:
97       - lf-infra-properties:
98           project: '{project}'
99           build-days-to-keep: 7
100
101     parameters:
102       - lf-infra-parameters:
103           project: '{project}'
104           branch: '{branch}'
105       - lf-infra-jjb-parameters:
106           jjb-version: '{jjb-version}'
107
108     wrappers:
109       - lf-infra-wrappers:
110           build-timeout: 10
111           jenkins-ssh-credential: '{jenkins-ssh-credential}'
112
113     publishers:
114       - lf-infra-publish
115
116 - job-template:
117     name: '{project-name}-jjb-merge'
118     id: gerrit-jjb-merge
119     <<: *lf_jjb_verify_merge
120     # yamllint disable-line rule:key-duplicates
121     <<: *lf_jjb_merge_builders
122
123     ######################
124     # Default parameters #
125     ######################
126
127     git-url: '$GIT_URL/$GERRIT_PROJECT'
128
129     #####################
130     # Job Configuration #
131     #####################
132
133     scm:
134       - lf-infra-gerrit-scm:
135           git-url: '{git-url}'
136           refspec: ''
137           branch: '{branch}'
138           submodule-recursive: '{submodule-recursive}'
139           choosing-strategy: default
140           jenkins-ssh-credential: '{jenkins-ssh-credential}'
141
142     triggers:
143       - gerrit:
144           server-name: '{gerrit-server-name}'
145           trigger-on:
146             - change-merged-event
147             - comment-added-contains-event:
148                 comment-contains-value: remerge$
149           projects:
150             - project-compare-type: ANT
151               project-pattern: '{project}'
152               branches:
153                 - branch-compare-type: ANT
154                   branch-pattern: '**/{branch}'
155               <<: *lf_jjb_file_paths
156
157 - job-template:
158     name: '{project-name}-jjb-verify'
159     id: gerrit-jjb-verify
160     concurrent: true
161     <<: *lf_jjb_verify_merge
162     # yamllint disable-line rule:key-duplicates
163     <<: *lf_jjb_verify_builders
164
165     ######################
166     # Default parameters #
167     ######################
168
169     git-url: '$GIT_URL/$GERRIT_PROJECT'
170
171     #####################
172     # Job Configuration #
173     #####################
174
175     scm:
176       - lf-infra-gerrit-scm:
177           git-url: '{git-url}'
178           refspec: '$GERRIT_REFSPEC'
179           branch: '$GERRIT_BRANCH'
180           submodule-recursive: '{submodule-recursive}'
181           choosing-strategy: gerrit
182           jenkins-ssh-credential: '{jenkins-ssh-credential}'
183
184     triggers:
185       - gerrit:
186           server-name: '{gerrit-server-name}'
187           trigger-on:
188             - patchset-created-event:
189                 exclude-drafts: false
190                 exclude-trivial-rebase: false
191                 exclude-no-code-change: false
192             - draft-published-event
193             - comment-added-contains-event:
194                 comment-contains-value: recheck$
195           projects:
196             - project-compare-type: ANT
197               project-pattern: '{project}'
198               branches:
199                 - branch-compare-type: ANT
200                   branch-pattern: '**/{branch}'
201               <<: *lf_jjb_file_paths
202
203 - job-template:
204     name: '{project-name}-jjb-merge'
205     id: github-jjb-merge
206     <<: *lf_jjb_verify_merge
207     # yamllint disable-line rule:key-duplicates
208     <<: *lf_jjb_merge_builders
209
210     ######################
211     # Default parameters #
212     ######################
213
214     github-url: https://github.com
215
216     #####################
217     # Job Configuration #
218     #####################
219
220     properties:
221       - github:
222           url: '{github-url}/{github-org}/{project}'
223
224     scm:
225       - lf-infra-github-scm:
226           url: 'git@github.com:{github-org}/{project}'
227           refspec: ''
228           branch: '{branch}'
229           submodule-recursive: '{submodule-recursive}'
230           choosing-strategy: default
231           jenkins-ssh-credential: '{jenkins-ssh-credential}'
232
233     triggers:
234       - github
235       - pollscm:
236           cron: ''
237       - github-pull-request:
238           trigger-phrase: '^remerge$'
239           only-trigger-phrase: true
240           status-context: 'JJB Merge'
241           permit-all: false
242           github-hooks: true
243           auto-close-on-fail: false
244           org-list:
245             - '{github-org}'
246
247 - job-template:
248     name: '{project-name}-jjb-verify'
249     id: github-jjb-verify
250     <<: *lf_jjb_verify_merge
251     # yamllint disable-line rule:key-duplicates
252     <<: *lf_jjb_merge_builders
253
254     ######################
255     # Default parameters #
256     ######################
257
258     github-url: https://github.com
259
260     #####################
261     # Job Configuration #
262     #####################
263
264     properties:
265       - github:
266           url: '{github-url}/{github-org}/{project}'
267
268     scm:
269       - lf-infra-github-scm:
270           url: 'git@github.com:{github-org}/{project}'
271           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
272           branch: '{branch}'
273           submodule-recursive: '{submodule-recursive}'
274           choosing-strategy: default
275           jenkins-ssh-credential: '{jenkins-ssh-credential}'
276
277     triggers:
278       - github-pull-request:
279           trigger-phrase: '^recheck$'
280           only-trigger-phrase: false
281           status-context: 'JJB Verify'
282           permit-all: true
283           github-hooks: true
284           auto-close-on-fail: false