Publish opnfvdocs pieman branch
[releng.git] / jjb / global / releng-macros.yaml
1 ---
2 # Releng macros
3 #
4 # NOTE: make sure macros are listed in execution ordered.
5 #
6 # 1. parameters/properties
7 # 2. scm
8 # 3. triggers
9 # 4. wrappers
10 # 5. prebuilders (maven only, configured like Builders)
11 # 6. builders (maven, freestyle, matrix, etc..)
12 # 7. postbuilders (maven only, configured like Builders)
13 # 8. publishers/reporters/notifications
14
15 - parameter:
16     name: project-parameter
17     parameters:
18       - string:
19           name: PROJECT
20           default: '{project}'
21           description: "JJB configured PROJECT parameter to identify an opnfv Gerrit project"
22       - string:
23           name: GS_BASE
24           default: artifacts.opnfv.org/$PROJECT
25           description: "URL to Google Storage."
26       - string:
27           name: GS_BASE_PROXY
28           default: build.opnfv.org/artifacts.opnfv.org/$PROJECT
29           description: "URL to Google Storage proxy"
30       - string:
31           name: BRANCH
32           default: '{branch}'
33           description: "JJB configured BRANCH parameter (e.g. master, stable/danube)"
34       - string:
35           name: GERRIT_BRANCH
36           default: '{branch}'
37           description: "JJB configured GERRIT_BRANCH parameter (deprecated)"
38       - string:
39           name: GERRIT_REFSPEC
40           default: 'refs/heads/{branch}'
41           description: "Default refspec needed for manually triggering."
42
43 ##
44 # Reporting Deployment Results
45 #
46 # To report deployment results to
47 # http://testresults.opnfv.org/test/#/deployresults, add the following
48 # parameters, builders, and publishers to a deployment job:
49 #
50 #   parameters:
51 #    - testapi-parameter
52 #
53 #   builders:
54 #    - track-begin-timestamp
55 #
56 #   publishers:
57 #    - report-provision-result
58 #
59 # Note: The following string parameter must also exist, as they are used
60 #       when reporting the provision result:
61 #
62 #  * INSTALLER
63 #  * INSTALLER_VERSION
64 #  * DEPLOY_SCENARIO
65 #
66 # most installers include these but you should verify first before
67 # adding the publisher, otherwise the deployment build may be marked
68 # unstable.
69 #
70 ##
71 - parameter:
72     name: testapi-parameter
73     parameters:
74       - string:
75           name: TESTAPI_URL
76           default: 'http://testresults.opnfv.org/test/api/v1'
77           description: "Default TestAPI URL, currently using v1"
78       - string:
79           name: INSTALLER_VERSION
80           default: 'master'
81           description: "Installer release version"
82       - string:
83           name: UPSTREAM_JOB_NAME
84           default: ''
85           description: "Parent job name in Jenkins"
86       - string:
87           name: UPSTREAM_BUILD_ID
88           default: ''
89           description: "Parent job build_id in Jenkins"
90
91 - property:
92     name: logrotate-default
93     properties:
94       - build-discarder:
95           days-to-keep: 60
96           num-to-keep: 200
97           artifact-days-to-keep: 60
98           artifact-num-to-keep: 200
99
100 - scm:
101     name: git-scm
102     scm:
103       - git: &git-scm-defaults
104           credentials-id: 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
105           url: '$GIT_BASE'
106           branches:
107             - 'origin/$BRANCH'
108           timeout: 15
109           per-build-tag: false
110           skip-tag: true
111           shallow-clone: false
112           use-author: false
113           ignore-notify: false
114           wipe-workspace: true
115           prune: false
116
117 - scm:
118     name: git-scm-gerrit
119     scm:
120       - git:
121           choosing-strategy: 'gerrit'
122           refspec: '$GERRIT_REFSPEC'
123           <<: *git-scm-defaults
124
125 - scm:
126     name: git-scm-gerrit-with-submodules
127     scm:
128       - git:
129           choosing-strategy: 'gerrit'
130           refspec: '$GERRIT_REFSPEC'
131           submodule:
132             recursive: true
133             timeout: 20
134           <<: *git-scm-defaults
135 - scm:
136     name: git-scm-with-submodules
137     scm:
138       - git:
139           credentials-id: 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
140           url: '$GIT_BASE'
141           refspec: ''
142           branches:
143             - 'refs/heads/{branch}'
144           per-build-tag: false
145           skip-tag: true
146           wipe-workspace: true
147           submodule:
148             recursive: true
149             timeout: 20
150
151 - scm:
152     name: git-scm-openstack
153     scm:
154       - git: &git-scm-openstack-defaults
155           per-build-tag: false
156           skip-tag: true
157           url: '$GIT_BASE'
158           branches:
159             - 'origin/$BRANCH'
160           timeout: 15
161
162 - trigger:
163     name: 'daily-trigger-disabled'
164     triggers:
165       - timed: ''
166
167 - trigger:
168     name: 'weekly-trigger-disabled'
169     triggers:
170       - timed: ''
171
172 - trigger:
173     name: gerrit-trigger-patchset-created
174     triggers:
175       - gerrit:
176           server-name: 'gerrit.opnfv.org'
177           trigger-on:
178             - patchset-created-event:
179                 exclude-drafts: 'false'
180                 exclude-trivial-rebase: 'false'
181                 exclude-no-code-change: 'false'
182             - draft-published-event
183             - comment-added-contains-event:
184                 comment-contains-value: 'recheck'
185             - comment-added-contains-event:
186                 comment-contains-value: 'reverify'
187           projects:
188             - project-compare-type: 'ANT'
189               project-pattern: '{project}'
190               branches:
191                 - branch-compare-type: 'ANT'
192                   branch-pattern: '**/{branch}'
193               file-paths:
194                 - compare-type: 'ANT'
195                   pattern: '{files}'
196           skip-vote:
197             successful: false
198             failed: false
199             unstable: false
200             notbuilt: false
201
202 - trigger:
203     name: gerrit-trigger-patchset-approved
204     triggers:
205       - gerrit:
206           server-name: 'gerrit.opnfv.org'
207           trigger-on:
208             - comment-added-event:
209                 approval-category: 'CRVW'
210                 approval-value: 2
211             - comment-added-contains-event:
212                 comment-contains-value: 'gate'
213           projects:
214             - project-compare-type: 'ANT'
215               project-pattern: '{project}'
216               branches:
217                 - branch-compare-type: 'ANT'
218                   branch-pattern: '**/{branch}'
219               file-paths:
220                 - compare-type: 'ANT'
221                   pattern: '{files}'
222           skip-vote:
223             successful: false
224             failed: false
225             unstable: false
226             notbuilt: false
227
228 - trigger:
229     name: gerrit-trigger-change-merged
230     triggers:
231       - gerrit:
232           server-name: 'gerrit.opnfv.org'
233           trigger-on:
234             - change-merged-event
235             - comment-added-contains-event:
236                 comment-contains-value: 'remerge'
237           projects:
238             - project-compare-type: 'ANT'
239               project-pattern: '{project}'
240               branches:
241                 - branch-compare-type: 'ANT'
242                   branch-pattern: '**/{branch}'
243               file-paths:
244                 - compare-type: 'ANT'
245                   pattern: '{files}'
246
247 - trigger:
248     name: gerrit-trigger-tag-created
249     triggers:
250       - gerrit:
251           server-name: 'gerrit.opnfv.org'
252           trigger-on:
253             - ref-updated-event
254           projects:
255             - project-compare-type: 'ANT'
256               project-pattern: '{project}'
257               branches:
258                 - branch-compare-type: 'ANT'
259                   branch-pattern: 'refs/tags/**'
260
261 - trigger:
262     name: 'experimental'
263     triggers:
264       - gerrit:
265           server-name: 'gerrit.opnfv.org'
266           trigger-on:
267             - comment-added-contains-event:
268                 comment-contains-value: 'check-experimental'
269           projects:
270             - project-compare-type: 'ANT'
271               project-pattern: '{project}'
272               branches:
273                 - branch-compare-type: 'ANT'
274                   branch-pattern: '**/{branch}'
275               file-paths:
276                 - compare-type: 'ANT'
277                   pattern: '{files}'
278           skip-vote:
279             successful: true
280             failed: true
281             unstable: true
282             notbuilt: true
283
284 - wrapper:
285     name: ssh-agent-wrapper
286     wrappers:
287       - ssh-agent-credentials:
288           users:
289             - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
290
291 - wrapper:
292     name: build-timeout
293     wrappers:
294       - timeout:
295           timeout: '{timeout}'
296           timeout-var: 'BUILD_TIMEOUT'
297           fail: true
298
299 - wrapper:
300     name: fix-workspace-permissions
301     wrappers:
302       - pre-scm-buildstep:
303           - shell: |
304              #!/bin/bash
305              sudo chown -R $USER:$USER $WORKSPACE || exit 1
306
307 - builder:
308     name: upload-under-review-docs-to-opnfv-artifacts
309     builders:
310       - shell: |
311           #!/bin/bash
312           set -o errexit
313           set -o pipefail
314           set -o xtrace
315           export PATH=$PATH:/usr/local/bin/
316
317           [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
318           [[ -d docs/_build/ ]] || exit 0
319
320           echo
321           echo "###########################"
322           echo "UPLOADING DOCS UNDER REVIEW"
323           echo "###########################"
324           echo
325
326           gs_base="artifacts.opnfv.org/$PROJECT/review"
327           gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
328           local_path="upload/$GERRIT_CHANGE_NUMBER"
329
330           mkdir -p upload
331           mv docs/_build/html/ "$local_path"
332           gsutil -m cp -r "$local_path" "gs://$gs_base"
333
334           gsutil -m setmeta \
335               -h "Content-Type:text/html" \
336               -h "Cache-Control:private, max-age=0, no-transform" \
337               "gs://$gs_path"/**.html > /dev/null 2>&1
338
339           echo "Document link(s):" >> gerrit_comment.txt
340           find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
341               sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
342
343 # To take advantage of this macro, have your build write
344 # out the file 'gerrit_comment.txt' with information to post
345 # back to gerrit and include this macro in the list of builders.
346 - builder:
347     name: report-build-result-to-gerrit
348     builders:
349       - shell: |
350           #!/bin/bash
351           set -o errexit
352           set -o pipefail
353           set -o xtrace
354           export PATH=$PATH:/usr/local/bin/
355           if [[ -e gerrit_comment.txt ]] ; then
356               echo
357               echo "posting review comment to gerrit..."
358               echo
359               cat gerrit_comment.txt
360               echo
361               ssh -o 'PubkeyAcceptedKeyTypes +ssh-rsa' \
362                   -p 29418 fbot@gerrit.opnfv.org \
363                   "gerrit review -p $GERRIT_PROJECT \
364                    -m '$(cat gerrit_comment.txt)' \
365                    $GERRIT_PATCHSET_REVISION \
366                    --notify NONE"
367           fi
368
369 - builder:
370     name: remove-old-docs-from-opnfv-artifacts
371     builders:
372       - shell: |
373           #!/bin/bash
374           set -o errexit
375           set -o pipefail
376           set -o xtrace
377           export PATH=$PATH:/usr/local/bin/
378
379           [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
380
381           gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
382
383           if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
384               echo
385               echo "Deleting Out-of-dated Documents..."
386               gsutil -m rm -r "gs://$gs_path"
387           fi
388           gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
389
390           if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
391               echo
392               echo "Deleting Out-of-dated Documents..."
393               gsutil -m rm -r "gs://$gs_path"
394           fi
395
396 - builder:
397     name: upload-review-docs
398     builders:
399       - upload-under-review-docs-to-opnfv-artifacts
400       - report-build-result-to-gerrit
401
402 - builder:
403     name: clean-workspace
404     builders:
405       - shell: |
406           #!/bin/bash
407           set -o errexit
408           set -o nounset
409           set -o pipefail
410           sudo /bin/rm -rf "$WORKSPACE"
411
412 - builder:
413     name: clean-workspace-log
414     builders:
415       - shell: |
416           find $WORKSPACE -type f -name '*.log' | xargs rm -f
417
418 - builder:
419     name: track-begin-timestamp
420     builders:
421       - shell: |
422           echo "export TIMESTAMP_START="\'`date '+%Y-%m-%d %H:%M:%S.%3N'`\' > $WORKSPACE/installer_track.sh
423
424 - publisher:
425     name: archive-artifacts
426     publishers:
427       - archive:
428           artifacts: '{artifacts}'
429           allow-empty: true
430           fingerprint: true
431           latest-only: true
432
433 - publisher:
434     name: publish-coverage
435     publishers:
436       - cobertura:
437           report-file: "coverage.xml"
438           only-stable: "true"
439           health-auto-update: "false"
440           stability-auto-update: "false"
441           zoom-coverage-chart: "true"
442           targets:
443             - files:
444                 healthy: 10
445                 unhealthy: 20
446                 failing: 30
447             - method:
448                 healthy: 50
449                 unhealthy: 40
450                 failing: 30
451
452 # The majority of the email-ext plugin options are set to the default
453 # for this macro so they can be managed through Jenkins' global
454 # settings.
455 - publisher:
456     name: email-jenkins-admins-on-failure
457     publishers:
458       - email-ext:
459           content-type: text
460           attach-build-log: true
461           compress-log: true
462           always: false
463           failure: true
464           send-to:
465             - recipients