Merge "Make Github url and clone url at Jenkins level."
[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     # Job Configuration #
212     #####################
213
214     properties:
215       - github:
216           url: '${{GIT_URL}}{github-org}/{project}'
217
218     scm:
219       - lf-infra-github-scm:
220           url: '${{GIT_CLONE_URL}}{github-org}/{project}'
221           refspec: ''
222           branch: '{branch}'
223           submodule-recursive: '{submodule-recursive}'
224           choosing-strategy: default
225           jenkins-ssh-credential: '{jenkins-ssh-credential}'
226
227     triggers:
228       - github
229       - pollscm:
230           cron: ''
231       - github-pull-request:
232           trigger-phrase: '^remerge$'
233           only-trigger-phrase: true
234           status-context: 'JJB Merge'
235           permit-all: false
236           github-hooks: true
237           auto-close-on-fail: false
238           org-list:
239             - '{github-org}'
240
241 - job-template:
242     name: '{project-name}-jjb-verify'
243     id: github-jjb-verify
244     <<: *lf_jjb_verify_merge
245     # yamllint disable-line rule:key-duplicates
246     <<: *lf_jjb_merge_builders
247
248     #####################
249     # Job Configuration #
250     #####################
251
252     properties:
253       - github:
254           url: '${{GIT_URL}}{github-org}/{project}'
255
256     scm:
257       - lf-infra-github-scm:
258           url: '${{GIT_CLONE_URL}}{github-org}/{project}'
259           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
260           branch: '{branch}'
261           submodule-recursive: '{submodule-recursive}'
262           choosing-strategy: default
263           jenkins-ssh-credential: '{jenkins-ssh-credential}'
264
265     triggers:
266       - github-pull-request:
267           trigger-phrase: '^recheck$'
268           only-trigger-phrase: false
269           status-context: 'JJB Verify'
270           permit-all: true
271           github-hooks: true
272           auto-close-on-fail: false