merge/verify jobs changed to subproject version
[ci-management.git] / jjb / global-macros.yaml
1 ---
2 # Global macros
3
4 # vim: sw=2 ts=2 sts=2 et :
5
6 # BUILDERS
7 - builder:
8     name: ci-management-check-unicode
9     builders:
10       - shell: |
11           $WORKSPACE/scripts/check-unicode.sh jjb/
12
13 - builder:
14     name: provide-maven-settings
15     builders:
16       - config-file-provider:
17           files:
18             - file-id: '{global-settings-file}'
19               variable: 'GLOBAL_SETTINGS_FILE'
20             - file-id: '{settings-file}'
21               variable: 'SETTINGS_FILE'
22
23 # PARAMETERS
24 - parameter:
25     name: ecomp-infra-parameters
26     parameters:
27       - string:
28           name: PROJECT
29           default: '{project}'
30           # yamllint disable rule:line-length
31           description: 'JJB configured PROJECT parameter to identify a Gerrit project'
32           # yamllint enable
33       - string:
34           name: ARCHIVE_ARTIFACTS
35           default: '{artifacts} **/target/surefire-reports/*-output.txt'
36           # yamllint disable rule:line-length
37           description: 'Space separated glob patterns for artifacts to archive to logs hosting'
38           # yamllint enable
39       - string:
40           name: GERRIT_BRANCH
41           default: '{branch}'
42           description: 'JJB configured GERRIT_BRANCH parameter'
43       - string:
44           name: GERRIT_PROJECT
45           default: '{project}'
46           description: 'GERRIT_PROJECT parameter if not given by trigger'
47       - string:
48           name: GERRIT_REFSPEC
49           default: '{refspec}'
50           description: 'GERRIT_REFSPEC parameter if not given by trigger'
51       - string:
52           name: STACK_NAME
53           default: '$JOB_NAME-$BUILD_NUMBER'
54           description: 'Used by Heat to generate a unique stack & vm name'
55
56 - parameter:
57     name: maven-exec
58     parameters:
59       - string:
60           name: MVN
61           # yamllint disable rule:line-length
62           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
63           # yamllint enable
64           description: 'Maven selector to be used by shell scripts'
65
66 # PROPERTIES
67 - property:
68     name: ecomp-infra-properties
69     properties:
70       - build-discarder:
71           days-to-keep: '{build-days-to-keep}'
72           num-to-keep: 40
73           artifact-days-to-keep: -1
74           artifact-num-to-keep: 5
75
76 # PUBLISHERS
77 - publisher:
78     name: archive-artifacts
79     publishers:
80       - archive:
81           artifacts: '{artifacts}'
82           allow-empty: true
83           fingerprint: true
84           latest-only: true
85
86 - publisher:
87     name: email-notification
88     publishers:
89       - email-ext:
90           recipients: 'nobody@open-o.org'
91           reply-to:
92           content-type: default
93           # yamllint disable rule:line-length
94           subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
95           # yamllint enable
96           body: |
97             $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
98
99             Check console output at $BUILD_URL to view the results.
100           unstable: true
101           fixed: true
102           send-to:
103             - developers
104             - recipients
105
106 - publisher:
107     name: jacoco-report
108     publishers:
109       - jacoco:
110           exec-pattern: '**/**.exec'
111           class-pattern: '**/classes'
112           source-pattern: '**/src/main/java'
113           # yamllint disable rule:line-length
114           exclusion-pattern: '**/gen**,**/generated-sources/**,**/yang-gen**,**/pax/**'
115           # yamllint enable
116           status-update: true
117           targets:
118             - branch:
119                 healthy: 10
120                 unhealthy: 20
121             - method:
122                 healthy: 50
123                 unhealthy: 40
124
125 - publisher:
126     name: ecomp-infra-shiplogs
127     # To archive things, the job will need to create an "archives" directory in
128     # the workspace and this macro will handle copying the contents of the
129     # archives directory.
130     #
131     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files to
132     # archive. You can pass globstar patterns for example "**/*.xml **/*.log" as
133     # the archive pattern. This is a space separated list of files to archive.
134     #
135     # Also ensure that the workspace is cleaned up at the end of the build.
136     publishers:
137       - postbuildscript:
138           builders:
139             - shell: !include-raw: include-raw-deploy-archives.sh
140             - maven-target:
141                 maven-version: '{maven-version}'
142                 pom: '.archives/deploy-archives.xml'
143                 goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
144                 settings: 'jenkins-log-archives-settings'
145                 settings-type: cfp
146                 global-settings: 'global-settings'
147                 global-settings-type: cfp
148             - description-setter:
149                 regexp: '^Build logs: .*'
150           script-only-if-succeeded: false
151           script-only-if-failed: false
152           mark-unstable-if-failed: true
153       - workspace-cleanup:
154           fail-build: false`
155
156 # SCMS
157 - scm:
158     name: git-scm
159     scm:
160       - git:
161           credentials-id: 'ecomp-jenkins-ssh'
162           url: '$GIT_BASE'
163           refspec: ''
164           branches:
165             - 'origin/{branch}'
166           skip-tag: true
167           wipe-workspace: true
168           timeout: 30
169
170 - scm:
171     name: gerrit-trigger-scm
172     scm:
173       - git:
174           credentials-id: 'ecomp-jenkins-ssh'
175           url: '$GIT_BASE'
176           refspec: '{refspec}'
177           branches:
178             - 'origin/$GERRIT_BRANCH'
179           skip-tag: true
180           timeout: 30
181           choosing-strategy: '{choosing-strategy}'
182
183 - scm:
184     name: gerrit-trigger-scm-basedir
185     scm:
186       - git:
187           credentials-id: 'ecomp-jenkins-ssh'
188           url: '$GIT_BASE'
189           refspec: '{refspec}'
190           branches:
191             - 'origin/$GERRIT_BRANCH'
192           skip-tag: true
193           timeout: 30
194           choosing-strategy: '{choosing-strategy}'
195           basedir: '{basedir}'
196
197 - scm:
198     name: git-branch-scm
199     scm:
200       - git:
201           credentials-id: 'ecomp-jenkins-ssh'
202           url: '$GIT_BASE'
203           refspec: ''
204           branches:
205             - 'origin/{branch}'
206           skip-tag: true
207           timeout: 30
208           wipe-workspace: true
209
210 - scm:
211     name: git-extra-project
212     scm:
213       - git:
214           credentials-id: 'ecomp-jenkins-ssh'
215           url: '$GIT_NO_PROJECT/{project}'
216           refspec: '{refspec}'
217           branches:
218             - 'origin/{branch}'
219           skip-tag: true
220           timeoute: 30
221           wipe-workspace: false
222           basedir: '{checkout-dir}'
223
224
225 # TRIGGERS
226
227 # This is a single macro to use for all jobs who vote on every (relevant) patch
228 # set. Only 'recheck' trigger word is supported, it always triggers the full set
229 # of relevant jobs, in order to prevent Jenkins from starting only a subset and
230 # still voting Verified+1
231 # Arguments:
232 #     server: name of gerrit server to listen to
233 #     project: pattern to match triggering projects
234 #     branch: triggering branch name
235 #     files: pattern to match triggering filepaths
236 - trigger:
237     name: gerrit-trigger-patch-submitted
238     triggers:
239       - gerrit:
240           server-name: '{server}'
241           trigger-on:
242             - patchset-created-event:
243                 exclude-drafts: 'false'
244                 exclude-trivial-rebase: 'false'
245                 exclude-no-code-change: 'false'
246             - draft-published-event
247             - comment-added-contains-event:
248                 comment-contains-value: 'recheck'
249           projects:
250             - project-compare-type: 'ANT'
251               project-pattern: '{project}'
252               branches:
253                 - branch-compare-type: 'ANT'
254                   branch-pattern: '**/{branch}'
255               file-paths:
256                 - compare-type: 'ANT'
257                   pattern: '{files}'
258
259 - trigger:
260     name: gerrit-trigger-patch-merged
261     triggers:
262       - gerrit:
263           server-name: '{server}'
264           trigger-on:
265             - change-merged-event
266             - comment-added-contains-event:
267                 comment-contains-value: 'remerge'
268           projects:
269             - project-compare-type: 'ANT'
270               project-pattern: '{project}'
271               branches:
272                 - branch-compare-type: 'ANT'
273                   branch-pattern: '**/{branch}'
274               file-paths:
275                 - compare-type: 'ANT'
276                   pattern: '{files}'
277
278 # WRAPPERS
279 - wrapper:
280     name: build-timeout
281     wrappers:
282       - timeout:
283           type: absolute
284           timeout: 360
285           fail: true
286
287 - wrapper:
288     # This wrapper is required for all jobs as it configures the wrappers
289     # needed by the eCOMP infra.
290     name: ecomp-infra-wrappers
291     wrappers:
292       - timeout:
293           type: absolute
294           timeout: '{build-timeout}'
295           timeout-var: 'BUILD_TIMEOUT'
296           fail: true
297       - ssh-agent-credentials:
298           users:
299             - 'ecomp-jenkins-ssh'
300       - openstack:
301           single-use: true