Fix yamllint for daexim
[releng/builder.git] / jjb / releng-macros.yaml
1 # OLD Releng macros
2
3 - property:
4     name: opendaylight-infra-properties
5     properties:
6         - build-discarder:
7             days-to-keep: '{build-days-to-keep}'
8
9 - parameter:
10     name: opendaylight-infra-parameters
11     parameters:
12         - string:
13             name: PROJECT
14             default: '{project}'
15             description: 'Parameter to identify an ODL Gerrit project'
16         - string:
17             name: ARCHIVE_ARTIFACTS
18             default: '{artifacts} **/target/surefire-reports/*-output.txt **/hs_err_*.log **/target/feature/feature.xml'
19             description: 'Space separated glob patterns for artifacts to archive into logs.opendaylight.org'
20         - string:
21             name: GERRIT_PROJECT
22             default: '{project}'
23             description: "GERRIT_PROJECT parameter if not given by trigger"
24         - string:
25             name: GERRIT_BRANCH
26             default: '{branch}'
27             description: "JJB configured GERRIT_BRANCH parameter"
28         - string:
29             name: GERRIT_REFSPEC
30             default: '{refspec}'
31             description: "GERRIT_REFSPEC parameter if not given by trigger"
32         - string:
33             name: STACK_NAME
34             default: '$JOB_NAME-$BUILD_NUMBER'
35             description: "Used by Heat to generate a unique stack & vm name"
36
37 - parameter:
38     name: build-tag
39     parameters:
40         - string:
41             name: BUILD_TAG
42             default: ''
43             description: 'Tag in Git to checkout'
44
45 - parameter:
46     name: controller-version-parameter
47     parameters:
48         - string:
49             name: ODL_VERSION
50             default: '{odl_version}'
51             description: 'Controller version (for use with openstacks networking_odl project)'
52
53 - parameter:
54     name: patches-to-build-parameter
55     parameters:
56         - string:
57             name: PATCHES_TO_BUILD
58             default: ''
59             description: 'csv list of patches in project:changeset format to build distribution with'
60
61 - parameter:
62     name: distribution-branch-to-build-parameter
63     parameters:
64         - string:
65             name: DISTRIBUTION_BRANCH_TO_BUILD
66             default: 'master'
67             description: 'distribution repo branch to build with'
68
69 - parameter:
70     name: p2zip-parameter
71     parameters:
72         - string:
73             name: P2ZIP_URL
74             default: ''
75             description: 'Nexus staging profile id'
76
77 - parameter:
78     name: stage-id-parameter
79     parameters:
80         - string:
81             name: STAGING_PROFILE_ID
82             default: '{stage-id}'
83             description: 'Nexus staging profile id'
84
85 - parameter:
86     name: maven-exec
87     parameters:
88       - string:
89           name: MVN
90           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
91           description: 'Maven selector to be used by shell scripts'
92
93 - scm:
94     name: git-scm
95     scm:
96         - git:
97             credentials-id: 'opendaylight-jenkins-ssh'
98             url: '$GIT_BASE'
99             refspec: ''
100             branches:
101                 - 'origin/{branch}'
102             skip-tag: true
103             wipe-workspace: true
104
105 - scm:
106     name: git-scm-with-submodules
107     scm:
108         - git:
109             credentials-id: 'opendaylight-jenkins-ssh'
110             url: '$GIT_BASE'
111             refspec: ''
112             branches:
113                 - 'refs/heads/{branch}'
114             skip-tag: true
115             wipe-workspace: true
116             submodule:
117                 recursive: true
118
119 - scm:
120     name: gerrit-trigger-scm
121     scm:
122         - git:
123             credentials-id: 'opendaylight-jenkins-ssh'
124             url: '$GIT_BASE'
125             refspec: '{refspec}'
126             branches:
127                 - 'origin/$GERRIT_BRANCH'
128             skip-tag: true
129             choosing-strategy: '{choosing-strategy}'
130
131 - wrapper:
132     name: build-timeout
133     wrappers:
134         - timeout:
135             type: absolute
136             timeout: 360
137             fail: true
138
139 # This is a single macro to use for all jobs who vote on every (relevant) patch set.
140 # Only 'recheck' trigger word is supported, it always triggers the full set of relevant jobs,
141 # in order to prevent Jenkins from starting only a subset and still voting Verified+1.
142 # Arguments:
143 #     server: name of gerrit server to listen to
144 #     project: pattern to match triggering projects
145 #     branch: triggering branch name
146 #     files: pattern to match triggering filepaths
147 - trigger:
148     name: gerrit-trigger-patch-submitted
149     triggers:
150         - gerrit:
151             server-name: '{server}'
152             trigger-on:
153                 - patchset-created-event:
154                     exclude-drafts: 'true'
155                     exclude-trivial-rebase: 'false'
156                     exclude-no-code-change: 'true'
157                 - draft-published-event
158                 - comment-added-contains-event:
159                     comment-contains-value: 'recheck'
160             projects:
161                 - project-compare-type: 'ANT'
162                   project-pattern: '{project}'
163                   branches:
164                       - branch-compare-type: 'ANT'
165                         branch-pattern: '**/{branch}'
166                   file-paths:
167                       - compare-type: 'ANT'
168                         pattern: '{files}'
169
170 # TODO: Unify argument names across gerrit-trigger-* macros.
171 - trigger:
172     name: gerrit-trigger-patch-merged
173     triggers:
174         - gerrit:
175             server-name: '{server-name}'
176             trigger-on:
177                 - change-merged-event
178                 - comment-added-contains-event:
179                     comment-contains-value: 'remerge'
180             projects:
181                 - project-compare-type: 'ANT'
182                   project-pattern: '{name}'
183                   branches:
184                       - branch-compare-type: 'ANT'
185                         branch-pattern: '**/{branch}'
186             skip-vote:
187                 successful: true
188                 failed: true
189                 unstable: true
190                 notbuilt: true
191             # Force Jenkins always vote the values it should already have voted
192             # during the prior verify phase
193             override-votes: true
194             gerrit-build-started-verified-value: 1
195             gerrit-build-successful-verified-value: 1
196             gerrit-build-failed-verified-value: 1
197             gerrit-build-unstable-verified-value: 1
198             gerrit-build-notbuilt-verified-value: 1
199             gerrit-build-started-codereview-value: 0
200             gerrit-build-successful-codereview-value: 0
201             gerrit-build-failed-codereview-value: 0
202             gerrit-build-unstable-codereview-value: 0
203             gerrit-build-notbuilt-codereview-value: 0
204
205 # TODO: Unify argument names across gerrit-trigger-* macros.
206 - trigger:
207     name: gerrit-trigger-patch-sonar
208     triggers:
209         - gerrit:
210             server-name: '{server-name}'
211             trigger-on:
212                 - comment-added-contains-event:
213                     comment-contains-value: 'run-sonar'
214             projects:
215               - project-compare-type: 'ANT'
216                 project-pattern: '{name}'
217                 branches:
218                   - branch-compare-type: 'ANT'
219                     branch-pattern: '**/master'
220             skip-vote:
221                 successful: true
222                 failed: true
223                 unstable: true
224                 notbuilt: true
225
226 - publisher:
227     name: archive-artifacts
228     publishers:
229         - archive:
230             artifacts: '{artifacts}'
231             allow-empty: true
232             fingerprint: true
233             latest-only: true
234
235 - publisher:
236     name: email-notification
237     publishers:
238         - email-ext:
239             recipients: '{email-recipients}'
240             reply-to: ''
241             content-type: default
242             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
243             body: |
244                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
245
246                 Please refer to the logs server URL for console logs when possible
247                 and use the Jenkins Build URL as a last resort.
248
249                 Console Logs URL:
250                 https://logs.opendaylight.org/$SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER
251
252                 Jenkins Build URL:
253                 $BUILD_URL
254             unstable: true
255             fixed: true
256             send-to:
257                 - recipients
258
259 - publisher:
260         name: jacoco-report
261         publishers:
262             - jacoco:
263                 exec-pattern: "**/**.exec"
264                 class-pattern: "**/classes"
265                 source-pattern: "**/src/main/java"
266                 exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**"
267                 status-update: true
268                 targets:
269                   - branch:
270                       healthy: 10
271                       unhealthy: 20
272                   - method:
273                       healthy: 50
274                       unhealthy: 40
275
276 - publisher:
277     name: opendaylight-infra-shiplogs
278     # To archive things the job will need to create a "archives" directory in
279     # the workspace and this macro will handle copying the contents of the
280     # archives directory.
281     #
282     # Uses the build parameter ARCHIVE_ARTIFACTS if not empty to find files
283     # to archive. You can pass globstar patterns for example "**/*.xml **/*.log"
284     # as the archive pattern. This is a space separated list of files to archive.
285     #
286     # Also ensure that the workspace is cleaned up at the end of the build.
287     publishers:
288         - postbuildscript:
289             builders:
290                 - shell: !include-raw: include-raw-stack-delete.sh
291                 - shell: !include-raw: include-raw-deploy-archives.sh
292                 - maven-target:
293                         maven-version: '{maven-version}'
294                         pom: '.archives/deploy-archives.xml'
295                         goals: 'clean deploy -V -B -q -Dmaven.repo.local=/tmp/r'
296                         settings: 'jenkins-log-archives-settings'
297                         settings-type: cfp
298                         global-settings: 'odl-global-settings'
299                         global-settings-type: cfp
300                 - description-setter:
301                     regexp: '^Build logs: .*'
302                 # Cleanup after ourselves
303                 - wipe-org-opendaylight-repo
304             script-only-if-succeeded: False
305             script-only-if-failed: False
306             mark-unstable-if-failed: True
307         - workspace-cleanup:
308             exclude:
309               # Do not clean up *.jenkins-trigger files for jobs that use a
310               # properties file as input for triggering another build.
311               - '**/*.jenkins-trigger'
312             fail-build: false
313
314 - builder:
315     name: opendaylight-infra-stack
316     # opendaylight-infra-stack.sh has a required variable {stack-template} that
317     # must be passed into this macro.
318     builders:
319         - shell: !include-raw: opendaylight-infra-stack.sh
320         - shell: !include-raw-escape: opendaylight-infra-copy-ssh-keys.sh
321
322 - builder:
323     name: opendaylight-infra-push-gerrit-patch
324     # opendaylight-infra-push-gerrit-patch.sh allows a job to push a patch to
325     # Gerrit in an automated fashion. This is meant for tasks that creates
326     # the same patch regularly and needs the ability to detect if an unreviewed
327     # patch already exists. In which case it will update the existing patch.
328     #
329     # Note: This patch assumes the $WORKSPACE contains the project repo with
330     #       the files changed already "git add" and waiting for a "git commit" call.
331     #
332     # This script requires the following JJB variables to be passed in:
333     #     {project}       Gerrit project-name
334     #     {gerrit-topic}  Gerrit topic, please make a unique topic.
335     #     {gerrit-commit-message} Commit message to assign to commit.
336     # NOTE: Requires git review to be installed on node.
337     builders:
338         - shell: !include-raw: opendaylight-infra-push-gerrit-patch.sh
339
340 - builder:
341     name: distribute-build-url
342     # Place URL of the current run of a build job to a file at given path.
343     builders:
344         - shell: 'echo "$BUILD_URL" > {path}/build.url'
345
346 - builder:
347     name: wipe-org-opendaylight-repo
348     builders:
349         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
350
351 - builder:
352     name: wipe-local-maven-repo
353     builders:
354         - shell: 'if [ -d /tmp/r ]; then rm -rf /tmp/r; fi'
355
356 - builder:
357     name: jacoco-nojava-workaround
358     builders:
359         - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
360
361 - builder:
362     name: check-clm
363     builders:
364         - sonatype-clm:
365             application-name: '{application-name}'
366
367 - builder:
368     name: releng-check-unicode
369     builders:
370         - shell: |
371             $WORKSPACE/scripts/check-unicode.sh jjb/
372
373 - builder:
374     name: provide-maven-settings
375     builders:
376     - config-file-provider:
377         files:
378         - file-id: '{global-settings-file}'
379           variable: 'GLOBAL_SETTINGS_FILE'
380         - file-id: '{settings-file}'
381           variable: 'SETTINGS_FILE'
382
383 - builder:
384     name: releng-fetch-p2zip-if-necessary
385     builders:
386     - shell: |
387         # Cleanup any existing zips and metadata before we download the new update site
388         rm -f *.zip *.xml
389     - conditional-step:
390         condition-kind: strings-match
391         condition-string1: '$P2ZIP_URL'
392         condition-string2: ''
393         condition-basedir: workspace
394         steps:
395             # TODO: Figure out latest snapshot version number to pull rather than hardcoding 1.1.1-SNAPSHOT
396             - maven-target:
397                 maven-version: '{maven-version}'
398                 goals: 'org.apache.maven.plugins:maven-dependency-plugin:get org.apache.maven.plugins:maven-dependency-plugin:copy -V -B -Dartifact=org.opendaylight.yangide:org.opendaylight.yangide.update-site:1.1.1-SNAPSHOT:zip -DoutputDirectory=$WORKSPACE'
399                 settings: '{settings}'
400                 global-settings: '{global-settings}'
401
402 - builder:
403     name: releng-generate-p2pom
404     builders:
405         - shell: !include-raw: include-raw-generate-p2pom.sh
406
407 - builder:
408     name: releng-update-p2composite-metadata
409     builders:
410     - shell: !include-raw: include-raw-update-p2composite-metadata.sh
411     - conditional-step:
412         condition-kind: file-exists
413         condition-filename: deploy-composite-repo.xml
414         condition-basedir: workspace
415         steps:
416             - maven-target:
417                 maven-version: '{maven-version}'
418                 pom: 'deploy-composite-repo.xml'
419                 goals: 'clean deploy -V -B -Dmaven.repo.local=/tmp/r'
420                 settings: '{settings}'
421                 global-settings: '{global-settings}'
422
423 - builder:
424     name: releng-stage-release
425     builders:
426         - shell: !include-raw: include-raw-stage-release.sh
427
428 - wrapper:
429     # This wrapper is required for all jobs as it configures the wrappers
430     # needed by OpenDaylight infra.
431     name: opendaylight-infra-wrappers
432     wrappers:
433         - mask-passwords
434         - config-file-provider:
435             files:
436                 - file-id: rackspace-heat
437                   target: '$HOME/.config/openstack/clouds.yaml'
438         - timeout:
439             type: absolute
440             timeout: '{build-timeout}'
441             timeout-var: 'BUILD_TIMEOUT'
442             fail: true
443         - timestamps
444         - ssh-agent-credentials:
445             users:
446                 - 'opendaylight-jenkins-ssh'
447         - openstack:
448             single-use: True
449
450 - builder:
451     name: packer-validate
452     builders:
453         - config-file-provider:
454             files:
455                 - file-id: 'packer-cloud-env'
456                   variable: 'CLOUDENV'
457         - shell: |
458             cd packer
459             varfiles="../packer/vars/*"
460             templates="../packer/templates/*"
461             provision="../packer/provision/*.sh"
462             for v in $varfiles; do
463                 [[ "${v##*/}" =~ ^(cloud-env.*)$ ]] && continue
464                 for t in $templates; do
465                     export PACKER_LOG="yes" && \
466                     export PACKER_LOG_PATH="packer-validate-${v##*/}-${t##*/}.log" && \
467                                 packer.io validate -var-file=$CLOUDENV \
468                                 -var-file=$v $t
469                     if [ $? -ne 0 ]; then
470                         break
471                     fi
472                 done
473             done
474             for p in $provision; do
475                 /bin/bash -n $p > provision-validate-${p##*/}.log 2>&1
476             done
477
478
479 - builder:
480     name: packer-build
481     builders:
482         - config-file-provider:
483             files:
484                 - file-id: 'packer-cloud-env'
485                   variable: 'CLOUDENV'
486         - shell: |
487             cd packer
488             export PACKER_LOG="yes" && \
489             export PACKER_LOG_PATH="packer-build.log" && \
490                         packer.io build -var-file=$CLOUDENV \
491                          -var-file=../packer/vars/{platform}.json \
492                          ../packer/templates/{template}.json
493
494 - builder:
495     # TODO: Verify signature after downloading users public key from a locally created
496     # repository instead of the public keymesh. This requires a process in place to get ODL
497     # developers public keys into a local repository without increasing the job thoughput.
498     name: verify-gpg-signature
499     builders:
500         - shell: !include-raw: include-raw-verify-gpg-signatures.sh
501
502 - builder:
503     name: opendaylight-infra-jjbini
504     builders:
505     - config-file-provider:
506           files:
507             - file-id: 'jjbini'
508               target: '$HOME/.config/jenkins_jobs/jenkins_jobs.ini'