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