Remove auto update bars
[releng.git] / jjb / global / releng-macros.yml
1 # Releng macros
2 #
3 # NOTE: make sure macros are listed in execution ordered.
4 #
5 # 1. parameters/properties
6 # 2. scm
7 # 3. triggers
8 # 4. wrappers
9 # 5. prebuilders (maven only, configured like Builders)
10 # 6. builders (maven, freestyle, matrix, etc..)
11 # 7. postbuilders (maven only, configured like Builders)
12 # 8. publishers/reporters/notifications
13
14 - parameter:
15     name: project-parameter
16     parameters:
17         - string:
18             name: PROJECT
19             default: '{project}'
20             description: "JJB configured PROJECT parameter to identify an opnfv Gerrit project"
21         - string:
22             name: GS_BASE
23             default: artifacts.opnfv.org/$PROJECT
24             description: "URL to Google Storage."
25         - string:
26             name: GS_BASE_PROXY
27             default: build.opnfv.org/artifacts.opnfv.org/$PROJECT
28             description: "URL to Google Storage proxy"
29         - string:
30             name: BRANCH
31             default: '{branch}'
32             description: "JJB configured BRANCH parameter (e.g. master, stable/danube)"
33         - string:
34             name: GERRIT_BRANCH
35             default: '{branch}'
36             description: "JJB configured GERRIT_BRANCH parameter (deprecated)"
37
38 - property:
39     name: logrotate-default
40     properties:
41         - build-discarder:
42             days-to-keep: 60
43             num-to-keep: 200
44             artifact-days-to-keep: 60
45             artifact-num-to-keep: 200
46
47 - scm:
48     name: git-scm
49     scm:
50         - git: &git-scm-defaults
51             credentials-id: '$SSH_CREDENTIAL_ID'
52             url: '$GIT_BASE'
53             branches:
54                 - 'origin/$BRANCH'
55             timeout: 15
56
57 - scm:
58     name: git-scm-gerrit
59     scm:
60         - git:
61             choosing-strategy: 'gerrit'
62             refspec: '$GERRIT_REFSPEC'
63             <<: *git-scm-defaults
64 - scm:
65     name: git-scm-with-submodules
66     scm:
67         - git:
68             credentials-id: '$SSH_CREDENTIAL_ID'
69             url: '$GIT_BASE'
70             refspec: ''
71             branches:
72                 - 'refs/heads/{branch}'
73             skip-tag: true
74             wipe-workspace: true
75             submodule:
76                 recursive: true
77                 timeout: 20
78                 shallow-clone: true
79 - trigger:
80     name: 'daily-trigger-disabled'
81     triggers:
82         - timed: ''
83
84 - trigger:
85     name: 'weekly-trigger-disabled'
86     triggers:
87         - timed: ''
88
89 - trigger:
90     name: gerrit-trigger-patchset-created
91     triggers:
92         - gerrit:
93             server-name: 'gerrit.opnfv.org'
94             trigger-on:
95                 - patchset-created-event:
96                     exclude-drafts: 'false'
97                     exclude-trivial-rebase: 'false'
98                     exclude-no-code-change: 'false'
99                 - draft-published-event
100                 - comment-added-contains-event:
101                     comment-contains-value: 'recheck'
102                 - comment-added-contains-event:
103                     comment-contains-value: 'reverify'
104             projects:
105               - project-compare-type: 'ANT'
106                 project-pattern: '{project}'
107                 branches:
108                   - branch-compare-type: 'ANT'
109                     branch-pattern: '**/{branch}'
110                 file-paths:
111                   - compare-type: 'ANT'
112                     pattern: '{files}'
113             skip-vote:
114                 successful: true
115                 failed: true
116                 unstable: true
117                 notbuilt: true
118
119 - trigger:
120     name: gerrit-trigger-change-merged
121     triggers:
122         - gerrit:
123             server-name: 'gerrit.opnfv.org'
124             trigger-on:
125                 - change-merged-event
126                 - comment-added-contains-event:
127                     comment-contains-value: 'remerge'
128             projects:
129               - project-compare-type: 'ANT'
130                 project-pattern: '{project}'
131                 branches:
132                   - branch-compare-type: 'ANT'
133                     branch-pattern: '**/{branch}'
134
135 - trigger:
136     name: 'experimental'
137     triggers:
138         - gerrit:
139             server-name: 'gerrit.opnfv.org'
140             trigger-on:
141                 - comment-added-contains-event:
142                     comment-contains-value: 'check-experimental'
143             projects:
144                 - project-compare-type: 'ANT'
145                   project-pattern: '{project}'
146                   branches:
147                       - branch-compare-type: 'ANT'
148                         branch-pattern: '**/{branch}'
149                   file-paths:
150                       - compare-type: 'ANT'
151                         pattern: 'tests/**'
152             skip-vote:
153                 successful: true
154                 failed: true
155                 unstable: true
156                 notbuilt: true
157
158 - wrapper:
159     name: ssh-agent-wrapper
160     wrappers:
161         - ssh-agent-credentials:
162             users:
163                 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
164
165 - builder:
166     name: build-html-and-pdf-docs-output
167     builders:
168         - shell: |
169             #!/bin/bash
170             set -o errexit
171             set -o xtrace
172             export PATH=$PATH:/usr/local/bin/
173             git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
174             GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
175
176 - builder:
177     name: upload-under-review-docs-to-opnfv-artifacts
178     builders:
179         - shell: |
180             #!/bin/bash
181             set -o errexit
182             set -o pipefail
183             set -o xtrace
184             export PATH=$PATH:/usr/local/bin/
185
186             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
187             [[ -d docs_output ]] || exit 0
188
189             echo
190             echo "###########################"
191             echo "UPLOADING DOCS UNDER REVIEW"
192             echo "###########################"
193             echo
194
195             gs_base="artifacts.opnfv.org/$PROJECT/review"
196             gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
197             local_path="upload/$GERRIT_CHANGE_NUMBER"
198
199             mkdir -p upload
200             mv docs_output "$local_path"
201             gsutil -m cp -r "$local_path" "gs://$gs_base"
202
203             gsutil -m setmeta \
204                 -h "Content-Type:text/html" \
205                 -h "Cache-Control:private, max-age=0, no-transform" \
206                 "gs://$gs_path"/**.html > /dev/null 2>&1
207
208             echo "Document link(s):" >> gerrit_comment.txt
209             find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
210                 sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
211
212 - builder:
213     name: upload-generated-docs-to-opnfv-artifacts
214     builders:
215         - shell: |
216             #!/bin/bash
217             set -o errexit
218             set -o pipefail
219             set -o xtrace
220             export PATH=$PATH:/usr/local/bin/
221
222             [[ -d docs_output ]] || exit 0
223
224             echo
225             echo "########################"
226             echo "UPLOADING GENERATED DOCS"
227             echo "########################"
228             echo
229
230             echo "gs_path="$GS_URL/docs""
231             echo "local_path="upload/docs""
232
233             gs_path="$GS_URL/docs"
234             local_path="upload/docs"
235
236             mkdir -p upload
237             mv docs_output "$local_path"
238             ls "$local_path"
239
240             echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
241             gsutil -m cp -r "$local_path"/* "gs://$gs_path"
242
243             gsutil -m setmeta \
244                 -h "Content-Type:text/html" \
245                 -h "Cache-Control:private, max-age=0, no-transform" \
246                 "gs://$gs_path"/**.html > /dev/null 2>&1
247
248             echo "Document link(s):" >> gerrit_comment.txt
249             find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
250                 sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
251
252 - builder:
253     name: report-docs-build-result-to-gerrit
254     builders:
255         - shell: |
256             #!/bin/bash
257             set -o errexit
258             set -o pipefail
259             set -o xtrace
260             export PATH=$PATH:/usr/local/bin/
261             if [[ -e gerrit_comment.txt ]] ; then
262                 echo
263                 echo "posting review comment to gerrit..."
264                 echo
265                 cat gerrit_comment.txt
266                 echo
267                 ssh -p 29418 gerrit.opnfv.org \
268                     "gerrit review -p $GERRIT_PROJECT \
269                      -m '$(cat gerrit_comment.txt)' \
270                      $GERRIT_PATCHSET_REVISION \
271                      --notify NONE"
272             fi
273
274 - builder:
275     name: remove-old-docs-from-opnfv-artifacts
276     builders:
277         - shell: |
278             #!/bin/bash
279             set -o errexit
280             set -o pipefail
281             set -o xtrace
282             export PATH=$PATH:/usr/local/bin/
283
284             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
285
286             gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
287
288             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
289                 echo
290                 echo "Deleting Out-of-dated Documents..."
291                 gsutil -m rm -r "gs://$gs_path"
292             fi
293             gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
294
295             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
296                 echo
297                 echo "Deleting Out-of-dated Documents..."
298                 gsutil -m rm -r "gs://$gs_path"
299             fi
300
301 - builder:
302     name: build-and-upload-artifacts-json-api
303     builders:
304         - shell: |
305             #!/bin/bash
306             set -o errexit
307             set -o pipefail
308             export PATH=$PATH:/usr/local/bin/
309
310             virtualenv -p python2.7 $WORKSPACE/releng_artifacts
311             source $WORKSPACE/releng_artifacts/bin/activate
312
313             # install python packages
314             pip install google-api-python-client
315
316             # generate and upload index file
317             echo "Generating Artifacts API ..."
318             python $WORKSPACE/utils/opnfv-artifacts.py > index.json
319             gsutil cp index.json gs://artifacts.opnfv.org/index.json
320
321             deactivate
322
323 - builder:
324     name: lint-python-code
325     builders:
326         - shell: |
327             #!/bin/bash
328             set -o errexit
329             set -o pipefail
330             set -o xtrace
331             export PATH=$PATH:/usr/local/bin/
332
333             virtualenv -p python2.7 $WORKSPACE/releng_flake8
334             source $WORKSPACE/releng_flake8/bin/activate
335
336             # install python packages
337             pip install "flake8==2.6.2"
338
339             # generate and upload lint log
340             echo "Running flake8 code on $PROJECT ..."
341
342             # Get number of flake8 violations. If none, this will be an
343             # empty string: ""
344             FLAKE_COUNT="$(find . \
345                 -path './releng_flake8' -prune -o \
346                 -path './.tox' -prune -o \
347                 -type f -name "*.py" -print | \
348                 xargs flake8 --exit-zero -qq --count 2>&1)"
349
350             # Ensure we start with a clean environment
351             rm -f lint.log
352
353             if [ ! -z $FLAKE_COUNT ]; then
354               echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
355               find . \
356                   -path './releng_flake8' -prune -o \
357                   -path './.tox' -prune -o \
358                   -type f -name "*.py" -print | \
359                   xargs flake8 --exit-zero --first >> violation.log
360               SHOWN=$(wc -l violation.log | cut -d' ' -f1)
361               echo -e "First $SHOWN shown\n---" >> lint.log
362               cat violation.log >> lint.log
363               sed -r -i '4,$s/^/ /g' lint.log
364               rm violation.log
365             fi
366
367             deactivate
368
369 - builder:
370     name: report-lint-result-to-gerrit
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             # If no violations were found, no lint log will exist.
380             if [[ -e lint.log ]] ; then
381                 echo -e "\nposting linting report to gerrit...\n"
382
383                 cat lint.log
384                 echo
385
386                 ssh -p 29418 gerrit.opnfv.org \
387                     "gerrit review -p $GERRIT_PROJECT \
388                      -m \"$(cat lint.log)\" \
389                      $GERRIT_PATCHSET_REVISION \
390                      --notify NONE"
391
392                 exit 1
393             fi
394
395 - builder:
396     name: upload-review-docs
397     builders:
398         - build-html-and-pdf-docs-output
399         - upload-under-review-docs-to-opnfv-artifacts
400         - report-docs-build-result-to-gerrit
401
402 - builder:
403     name: upload-merged-docs
404     builders:
405         - build-html-and-pdf-docs-output
406         - upload-generated-docs-to-opnfv-artifacts
407         - report-docs-build-result-to-gerrit
408         - remove-old-docs-from-opnfv-artifacts
409
410 - builder:
411     name: check-bash-syntax
412     builders:
413         - shell: "find . -name '*.sh' | xargs bash -n"
414
415 - builder:
416     name: lint-yaml-code
417     builders:
418         - shell: |
419             #!/bin/bash
420             set -o errexit
421             set -o pipefail
422             set -o xtrace
423             export PATH=$PATH:/usr/local/bin/
424
425             # install python packages
426             pip install "yamllint==1.6.0"
427
428             # generate and upload lint log
429             echo "Running yaml code on $PROJECT ..."
430
431             # Ensure we start with a clean environment
432             rm -f yaml-violation.log lint.log
433
434             # Get number of yaml violations. If none, this will be an
435             # empty string: ""
436             find . \
437                 -type f -name "*.yml" -print \
438                 -o -name "*.yaml" -print | \
439                 xargs yamllint > yaml-violation.log || true
440
441             if [ -s "yaml-violation.log" ]; then
442               SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
443               echo -e "First $SHOWN shown\n---" > lint.log
444               cat yaml-violation.log >> lint.log
445               sed -r -i '4,$s/^/ /g' lint.log
446             fi
447
448 - builder:
449     name: clean-workspace-log
450     builders:
451         - shell: |
452             find $WORKSPACE -type f -name '*.log' | xargs rm -f
453
454 - publisher:
455     name: archive-artifacts
456     publishers:
457         - archive:
458             artifacts: '{artifacts}'
459             allow-empty: true
460             fingerprint: true
461             latest-only: true
462
463 - publisher:
464     name: publish-coverage
465     publishers:
466       - cobertura:
467           report-file: "coverage.xml"
468           only-stable: "true"
469           health-auto-update: "false"
470           stability-auto-update: "false"
471           zoom-coverage-chart: "true"
472           targets:
473             - files:
474                 healthy: 10
475                 unhealthy: 20
476                 failing: 30
477             - method:
478                 healthy: 50
479                 unhealthy: 40
480                 failing: 30
481