3 # NOTE: make sure macros are listed in execution ordered.
5 # 1. parameters/properties
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
15 name: project-parameter
20 description: "JJB configured PROJECT parameter to identify an opnfv Gerrit project"
23 default: artifacts.opnfv.org/$PROJECT
24 description: "URL to Google Storage."
27 default: build.opnfv.org/artifacts.opnfv.org/$PROJECT
28 description: "URL to Google Storage proxy"
32 description: "JJB configured BRANCH parameter (e.g. master, stable/danube)"
36 description: "JJB configured GERRIT_BRANCH parameter (deprecated)"
39 name: logrotate-default
44 artifact-days-to-keep: 60
45 artifact-num-to-keep: 200
50 - git: &git-scm-defaults
51 credentials-id: '$SSH_CREDENTIAL_ID'
61 choosing-strategy: 'gerrit'
62 refspec: '$GERRIT_REFSPEC'
65 name: git-scm-with-submodules
68 credentials-id: '$SSH_CREDENTIAL_ID'
72 - 'refs/heads/{branch}'
79 name: 'daily-trigger-disabled'
84 name: 'weekly-trigger-disabled'
89 name: gerrit-trigger-patchset-created
92 server-name: 'gerrit.opnfv.org'
94 - patchset-created-event:
95 exclude-drafts: 'false'
96 exclude-trivial-rebase: 'false'
97 exclude-no-code-change: 'false'
98 - draft-published-event
99 - comment-added-contains-event:
100 comment-contains-value: 'recheck'
101 - comment-added-contains-event:
102 comment-contains-value: 'reverify'
104 - project-compare-type: 'ANT'
105 project-pattern: '{project}'
107 - branch-compare-type: 'ANT'
108 branch-pattern: '**/{branch}'
110 - compare-type: 'ANT'
119 name: gerrit-trigger-change-merged
122 server-name: 'gerrit.opnfv.org'
124 - change-merged-event
125 - comment-added-contains-event:
126 comment-contains-value: 'remerge'
128 - project-compare-type: 'ANT'
129 project-pattern: '{project}'
131 - branch-compare-type: 'ANT'
132 branch-pattern: '**/{branch}'
134 - compare-type: 'ANT'
141 server-name: 'gerrit.opnfv.org'
143 - comment-added-contains-event:
144 comment-contains-value: 'check-experimental'
146 - project-compare-type: 'ANT'
147 project-pattern: '{project}'
149 - branch-compare-type: 'ANT'
150 branch-pattern: '**/{branch}'
152 - compare-type: 'ANT'
161 name: ssh-agent-wrapper
163 - ssh-agent-credentials:
165 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
168 name: fix-workspace-permissions
173 sudo chown -R $USER:$USER $WORKSPACE || exit 1
176 name: build-html-and-pdf-docs-output
182 export PATH=$PATH:/usr/local/bin/
183 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
184 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
187 name: upload-under-review-docs-to-opnfv-artifacts
194 export PATH=$PATH:/usr/local/bin/
196 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
197 [[ -d docs_output ]] || exit 0
200 echo "###########################"
201 echo "UPLOADING DOCS UNDER REVIEW"
202 echo "###########################"
205 gs_base="artifacts.opnfv.org/$PROJECT/review"
206 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
207 local_path="upload/$GERRIT_CHANGE_NUMBER"
210 mv docs_output "$local_path"
211 gsutil -m cp -r "$local_path" "gs://$gs_base"
214 -h "Content-Type:text/html" \
215 -h "Cache-Control:private, max-age=0, no-transform" \
216 "gs://$gs_path"/**.html > /dev/null 2>&1
218 echo "Document link(s):" >> gerrit_comment.txt
219 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
220 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
223 name: upload-generated-docs-to-opnfv-artifacts
230 export PATH=$PATH:/usr/local/bin/
232 [[ -d docs_output ]] || exit 0
235 echo "########################"
236 echo "UPLOADING GENERATED DOCS"
237 echo "########################"
240 echo "gs_path="$GS_URL/docs""
241 echo "local_path="upload/docs""
243 gs_path="$GS_URL/docs"
244 local_path="upload/docs"
247 mv docs_output "$local_path"
250 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
251 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
254 -h "Content-Type:text/html" \
255 -h "Cache-Control:private, max-age=0, no-transform" \
256 "gs://$gs_path"/**.html > /dev/null 2>&1
258 echo "Document link(s):" >> gerrit_comment.txt
259 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
260 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
262 # To take advantage of this macro, have your build write
263 # out the file 'gerrit_comment.txt' with information to post
264 # back to gerrit and include this macro in the list of builders.
266 name: report-build-result-to-gerrit
273 export PATH=$PATH:/usr/local/bin/
274 if [[ -e gerrit_comment.txt ]] ; then
276 echo "posting review comment to gerrit..."
278 cat gerrit_comment.txt
280 ssh -p 29418 gerrit.opnfv.org \
281 "gerrit review -p $GERRIT_PROJECT \
282 -m '$(cat gerrit_comment.txt)' \
283 $GERRIT_PATCHSET_REVISION \
288 name: remove-old-docs-from-opnfv-artifacts
295 export PATH=$PATH:/usr/local/bin/
297 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
299 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
301 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
303 echo "Deleting Out-of-dated Documents..."
304 gsutil -m rm -r "gs://$gs_path"
306 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
308 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
310 echo "Deleting Out-of-dated Documents..."
311 gsutil -m rm -r "gs://$gs_path"
315 name: build-and-upload-artifacts-json-api
321 export PATH=$PATH:/usr/local/bin/
323 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
324 source $WORKSPACE/releng_artifacts/bin/activate
326 # install python packages
327 pip install google-api-python-client
329 # generate and upload index file
330 echo "Generating Artifacts API ..."
331 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
332 gsutil cp index.json gs://artifacts.opnfv.org/index.json
337 name: lint-python-code
344 export PATH=$PATH:/usr/local/bin/
346 virtualenv -p python2.7 $WORKSPACE/releng_flake8
347 source $WORKSPACE/releng_flake8/bin/activate
349 # install python packages
350 pip install "flake8==2.6.2"
352 # generate and upload lint log
353 echo "Running flake8 code on $PROJECT ..."
355 # Get number of flake8 violations. If none, this will be an
357 FLAKE_COUNT="$(find . \
358 -path './releng_flake8' -prune -o \
359 -path './.tox' -prune -o \
360 -type f -name "*.py" -print | \
361 xargs flake8 --exit-zero -qq --count 2>&1)"
363 # Ensure we start with a clean environment
366 if [ ! -z $FLAKE_COUNT ]; then
367 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
369 -path './releng_flake8' -prune -o \
370 -path './.tox' -prune -o \
371 -type f -name "*.py" -print | \
372 xargs flake8 --exit-zero --first >> violation.log
373 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
374 echo -e "First $SHOWN shown\n---" >> lint.log
375 cat violation.log >> lint.log
376 sed -r -i '4,$s/^/ /g' lint.log
383 name: report-lint-result-to-gerrit
390 export PATH=$PATH:/usr/local/bin/
392 # If no violations were found, no lint log will exist.
393 if [[ -e lint.log ]] ; then
394 echo -e "\nposting linting report to gerrit...\n"
399 ssh -p 29418 gerrit.opnfv.org \
400 "gerrit review -p $GERRIT_PROJECT \
401 -m \"$(cat lint.log)\" \
402 $GERRIT_PATCHSET_REVISION \
409 name: upload-review-docs
411 - build-html-and-pdf-docs-output
412 - upload-under-review-docs-to-opnfv-artifacts
413 - report-build-result-to-gerrit
416 name: upload-merged-docs
418 - build-html-and-pdf-docs-output
419 - upload-generated-docs-to-opnfv-artifacts
420 - report-build-result-to-gerrit
421 - remove-old-docs-from-opnfv-artifacts
424 name: check-bash-syntax
426 - shell: "find . -name '*.sh' | xargs bash -n"
436 export PATH=$PATH:/usr/local/bin/
438 # install python packages
439 pip install "yamllint==1.6.0"
441 # generate and upload lint log
442 echo "Running yaml code on $PROJECT ..."
444 # Ensure we start with a clean environment
445 rm -f yaml-violation.log lint.log
447 # Get number of yaml violations. If none, this will be an
450 -type f -name "*.yml" -print \
451 -o -name "*.yaml" -print | \
452 xargs yamllint > yaml-violation.log || true
454 if [ -s "yaml-violation.log" ]; then
455 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
456 echo -e "First $SHOWN shown\n---" > lint.log
457 cat yaml-violation.log >> lint.log
458 sed -r -i '4,$s/^/ /g' lint.log
462 name: clean-workspace-log
465 find $WORKSPACE -type f -name '*.log' | xargs rm -f
468 name: archive-artifacts
471 artifacts: '{artifacts}'
477 name: publish-coverage
480 report-file: "coverage.xml"
482 health-auto-update: "false"
483 stability-auto-update: "false"
484 zoom-coverage-chart: "true"
495 # The majority of the email-ext plugin options are set to the default
496 # for this macro so they can be managed through Jenkins' global
499 name: email-jenkins-admins-on-failure
503 attach-build-log: true