4 # NOTE: make sure macros are listed in execution ordered.
6 # 1. parameters/properties
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
16 name: project-parameter
21 description: "JJB configured PROJECT parameter to identify an opnfv Gerrit project"
24 default: artifacts.opnfv.org/$PROJECT
25 description: "URL to Google Storage."
28 default: build.opnfv.org/artifacts.opnfv.org/$PROJECT
29 description: "URL to Google Storage proxy"
33 description: "JJB configured BRANCH parameter (e.g. master, stable/danube)"
37 description: "JJB configured GERRIT_BRANCH parameter (deprecated)"
40 name: logrotate-default
45 artifact-days-to-keep: 60
46 artifact-num-to-keep: 200
51 - git: &git-scm-defaults
52 credentials-id: '$SSH_CREDENTIAL_ID'
62 choosing-strategy: 'gerrit'
63 refspec: '$GERRIT_REFSPEC'
66 name: git-scm-with-submodules
69 credentials-id: '$SSH_CREDENTIAL_ID'
73 - 'refs/heads/{branch}'
80 name: 'daily-trigger-disabled'
85 name: 'weekly-trigger-disabled'
90 name: gerrit-trigger-patchset-created
93 server-name: 'gerrit.opnfv.org'
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'
105 - project-compare-type: 'ANT'
106 project-pattern: '{project}'
108 - branch-compare-type: 'ANT'
109 branch-pattern: '**/{branch}'
111 - compare-type: 'ANT'
120 name: gerrit-trigger-change-merged
123 server-name: 'gerrit.opnfv.org'
125 - change-merged-event
126 - comment-added-contains-event:
127 comment-contains-value: 'remerge'
129 - project-compare-type: 'ANT'
130 project-pattern: '{project}'
132 - branch-compare-type: 'ANT'
133 branch-pattern: '**/{branch}'
135 - compare-type: 'ANT'
139 name: gerrit-trigger-tag-created
142 server-name: 'gerrit.opnfv.org'
146 - project-compare-type: 'ANT'
147 project-pattern: '{project}'
149 - branch-compare-type: 'ANT'
150 branch-pattern: 'refs/tags/**'
156 server-name: 'gerrit.opnfv.org'
158 - comment-added-contains-event:
159 comment-contains-value: 'check-experimental'
161 - project-compare-type: 'ANT'
162 project-pattern: '{project}'
164 - branch-compare-type: 'ANT'
165 branch-pattern: '**/{branch}'
167 - compare-type: 'ANT'
176 name: ssh-agent-wrapper
178 - ssh-agent-credentials:
180 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
187 timeout-var: 'BUILD_TIMEOUT'
191 name: fix-workspace-permissions
196 sudo chown -R $USER:$USER $WORKSPACE || exit 1
199 name: build-html-and-pdf-docs-output
205 export PATH=$PATH:/usr/local/bin/
206 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
207 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
210 name: upload-under-review-docs-to-opnfv-artifacts
217 export PATH=$PATH:/usr/local/bin/
219 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
220 [[ -d docs_output ]] || exit 0
223 echo "###########################"
224 echo "UPLOADING DOCS UNDER REVIEW"
225 echo "###########################"
228 gs_base="artifacts.opnfv.org/$PROJECT/review"
229 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
230 local_path="upload/$GERRIT_CHANGE_NUMBER"
233 mv docs_output "$local_path"
234 gsutil -m cp -r "$local_path" "gs://$gs_base"
237 -h "Content-Type:text/html" \
238 -h "Cache-Control:private, max-age=0, no-transform" \
239 "gs://$gs_path"/**.html > /dev/null 2>&1
241 echo "Document link(s):" >> gerrit_comment.txt
242 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
243 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
246 name: upload-generated-docs-to-opnfv-artifacts
253 export PATH=$PATH:/usr/local/bin/
255 [[ -d docs_output ]] || exit 0
258 echo "########################"
259 echo "UPLOADING GENERATED DOCS"
260 echo "########################"
263 echo "gs_path="$GS_URL/docs""
264 echo "local_path="upload/docs""
266 gs_path="$GS_URL/docs"
267 local_path="upload/docs"
270 mv docs_output "$local_path"
273 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
274 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
277 -h "Content-Type:text/html" \
278 -h "Cache-Control:private, max-age=0, no-transform" \
279 "gs://$gs_path"/**.html > /dev/null 2>&1
281 echo "Document link(s):" >> gerrit_comment.txt
282 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
283 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
285 # To take advantage of this macro, have your build write
286 # out the file 'gerrit_comment.txt' with information to post
287 # back to gerrit and include this macro in the list of builders.
289 name: report-build-result-to-gerrit
296 export PATH=$PATH:/usr/local/bin/
297 if [[ -e gerrit_comment.txt ]] ; then
299 echo "posting review comment to gerrit..."
301 cat gerrit_comment.txt
303 ssh -p 29418 gerrit.opnfv.org \
304 "gerrit review -p $GERRIT_PROJECT \
305 -m '$(cat gerrit_comment.txt)' \
306 $GERRIT_PATCHSET_REVISION \
311 name: remove-old-docs-from-opnfv-artifacts
318 export PATH=$PATH:/usr/local/bin/
320 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
322 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
324 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
326 echo "Deleting Out-of-dated Documents..."
327 gsutil -m rm -r "gs://$gs_path"
329 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
331 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
333 echo "Deleting Out-of-dated Documents..."
334 gsutil -m rm -r "gs://$gs_path"
338 name: build-and-upload-artifacts-json-api
344 export PATH=$PATH:/usr/local/bin/
346 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
347 source $WORKSPACE/releng_artifacts/bin/activate
349 # install python packages
350 pip install google-api-python-client
352 # generate and upload index file
353 echo "Generating Artifacts API ..."
354 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
355 gsutil cp index.json gs://artifacts.opnfv.org/index.json
360 name: lint-python-code
367 export PATH=$PATH:/usr/local/bin/
369 virtualenv -p python2.7 $WORKSPACE/releng_flake8
370 source $WORKSPACE/releng_flake8/bin/activate
372 # install python packages
373 pip install "flake8==2.6.2"
375 # generate and upload lint log
376 echo "Running flake8 code on $PROJECT ..."
378 # Get number of flake8 violations. If none, this will be an
380 FLAKE_COUNT="$(find . \
381 -path './releng_flake8' -prune -o \
382 -path './.tox' -prune -o \
383 -type f -name "*.py" -print | \
384 xargs flake8 --exit-zero -qq --count 2>&1)"
386 # Ensure we start with a clean environment
389 if [ ! -z $FLAKE_COUNT ]; then
390 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
392 -path './releng_flake8' -prune -o \
393 -path './.tox' -prune -o \
394 -type f -name "*.py" -print | \
395 xargs flake8 --exit-zero --first >> violation.log
396 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
397 echo -e "First $SHOWN shown\n---" >> lint.log
398 cat violation.log >> lint.log
399 sed -r -i '4,$s/^/ /g' lint.log
406 name: report-lint-result-to-gerrit
413 export PATH=$PATH:/usr/local/bin/
415 # If no violations were found, no lint log will exist.
416 if [[ -e lint.log ]] ; then
417 echo -e "\nposting linting report to gerrit...\n"
422 ssh -p 29418 gerrit.opnfv.org \
423 "gerrit review -p $GERRIT_PROJECT \
424 -m \"$(cat lint.log)\" \
425 $GERRIT_PATCHSET_REVISION \
432 name: upload-review-docs
434 - build-html-and-pdf-docs-output
435 - upload-under-review-docs-to-opnfv-artifacts
436 - report-build-result-to-gerrit
439 name: upload-merged-docs
441 - build-html-and-pdf-docs-output
442 - upload-generated-docs-to-opnfv-artifacts
443 - report-build-result-to-gerrit
444 - remove-old-docs-from-opnfv-artifacts
447 name: check-bash-syntax
449 - shell: "find . -name '*.sh' | xargs bash -n"
459 export PATH=$PATH:/usr/local/bin/
461 # install python packages
462 pip install "yamllint==1.6.0"
464 # generate and upload lint log
465 echo "Running yaml code on $PROJECT ..."
467 # Ensure we start with a clean environment
468 rm -f yaml-violation.log lint.log
470 # Get number of yaml violations. If none, this will be an
473 -type f -name "*.yml" -print \
474 -o -name "*.yaml" -print | \
475 xargs yamllint > yaml-violation.log || true
477 if [ -s "yaml-violation.log" ]; then
478 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
479 echo -e "First $SHOWN shown\n---" > lint.log
480 cat yaml-violation.log >> lint.log
481 sed -r -i '4,$s/^/ /g' lint.log
485 name: clean-workspace
492 sudo /bin/rm -rf "$WORKSPACE"
495 name: clean-workspace-log
498 find $WORKSPACE -type f -name '*.log' | xargs rm -f
501 name: archive-artifacts
504 artifacts: '{artifacts}'
510 name: publish-coverage
513 report-file: "coverage.xml"
515 health-auto-update: "false"
516 stability-auto-update: "false"
517 zoom-coverage-chart: "true"
528 # The majority of the email-ext plugin options are set to the default
529 # for this macro so they can be managed through Jenkins' global
532 name: email-jenkins-admins-on-failure
536 attach-build-log: true