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'
142 server-name: 'gerrit.opnfv.org'
144 - comment-added-contains-event:
145 comment-contains-value: 'check-experimental'
147 - project-compare-type: 'ANT'
148 project-pattern: '{project}'
150 - branch-compare-type: 'ANT'
151 branch-pattern: '**/{branch}'
153 - compare-type: 'ANT'
162 name: ssh-agent-wrapper
164 - ssh-agent-credentials:
166 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
173 timeout-var: 'BUILD_TIMEOUT'
177 name: fix-workspace-permissions
182 sudo chown -R $USER:$USER $WORKSPACE || exit 1
185 name: build-html-and-pdf-docs-output
191 export PATH=$PATH:/usr/local/bin/
192 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
193 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
196 name: upload-under-review-docs-to-opnfv-artifacts
203 export PATH=$PATH:/usr/local/bin/
205 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
206 [[ -d docs_output ]] || exit 0
209 echo "###########################"
210 echo "UPLOADING DOCS UNDER REVIEW"
211 echo "###########################"
214 gs_base="artifacts.opnfv.org/$PROJECT/review"
215 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
216 local_path="upload/$GERRIT_CHANGE_NUMBER"
219 mv docs_output "$local_path"
220 gsutil -m cp -r "$local_path" "gs://$gs_base"
223 -h "Content-Type:text/html" \
224 -h "Cache-Control:private, max-age=0, no-transform" \
225 "gs://$gs_path"/**.html > /dev/null 2>&1
227 echo "Document link(s):" >> gerrit_comment.txt
228 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
229 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
232 name: upload-generated-docs-to-opnfv-artifacts
239 export PATH=$PATH:/usr/local/bin/
241 [[ -d docs_output ]] || exit 0
244 echo "########################"
245 echo "UPLOADING GENERATED DOCS"
246 echo "########################"
249 echo "gs_path="$GS_URL/docs""
250 echo "local_path="upload/docs""
252 gs_path="$GS_URL/docs"
253 local_path="upload/docs"
256 mv docs_output "$local_path"
259 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
260 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
263 -h "Content-Type:text/html" \
264 -h "Cache-Control:private, max-age=0, no-transform" \
265 "gs://$gs_path"/**.html > /dev/null 2>&1
267 echo "Document link(s):" >> gerrit_comment.txt
268 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
269 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
271 # To take advantage of this macro, have your build write
272 # out the file 'gerrit_comment.txt' with information to post
273 # back to gerrit and include this macro in the list of builders.
275 name: report-build-result-to-gerrit
282 export PATH=$PATH:/usr/local/bin/
283 if [[ -e gerrit_comment.txt ]] ; then
285 echo "posting review comment to gerrit..."
287 cat gerrit_comment.txt
289 ssh -p 29418 gerrit.opnfv.org \
290 "gerrit review -p $GERRIT_PROJECT \
291 -m '$(cat gerrit_comment.txt)' \
292 $GERRIT_PATCHSET_REVISION \
297 name: remove-old-docs-from-opnfv-artifacts
304 export PATH=$PATH:/usr/local/bin/
306 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
308 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
310 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
312 echo "Deleting Out-of-dated Documents..."
313 gsutil -m rm -r "gs://$gs_path"
315 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
317 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
319 echo "Deleting Out-of-dated Documents..."
320 gsutil -m rm -r "gs://$gs_path"
324 name: build-and-upload-artifacts-json-api
330 export PATH=$PATH:/usr/local/bin/
332 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
333 source $WORKSPACE/releng_artifacts/bin/activate
335 # install python packages
336 pip install google-api-python-client
338 # generate and upload index file
339 echo "Generating Artifacts API ..."
340 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
341 gsutil cp index.json gs://artifacts.opnfv.org/index.json
346 name: lint-python-code
353 export PATH=$PATH:/usr/local/bin/
355 virtualenv -p python2.7 $WORKSPACE/releng_flake8
356 source $WORKSPACE/releng_flake8/bin/activate
358 # install python packages
359 pip install "flake8==2.6.2"
361 # generate and upload lint log
362 echo "Running flake8 code on $PROJECT ..."
364 # Get number of flake8 violations. If none, this will be an
366 FLAKE_COUNT="$(find . \
367 -path './releng_flake8' -prune -o \
368 -path './.tox' -prune -o \
369 -type f -name "*.py" -print | \
370 xargs flake8 --exit-zero -qq --count 2>&1)"
372 # Ensure we start with a clean environment
375 if [ ! -z $FLAKE_COUNT ]; then
376 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
378 -path './releng_flake8' -prune -o \
379 -path './.tox' -prune -o \
380 -type f -name "*.py" -print | \
381 xargs flake8 --exit-zero --first >> violation.log
382 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
383 echo -e "First $SHOWN shown\n---" >> lint.log
384 cat violation.log >> lint.log
385 sed -r -i '4,$s/^/ /g' lint.log
392 name: report-lint-result-to-gerrit
399 export PATH=$PATH:/usr/local/bin/
401 # If no violations were found, no lint log will exist.
402 if [[ -e lint.log ]] ; then
403 echo -e "\nposting linting report to gerrit...\n"
408 ssh -p 29418 gerrit.opnfv.org \
409 "gerrit review -p $GERRIT_PROJECT \
410 -m \"$(cat lint.log)\" \
411 $GERRIT_PATCHSET_REVISION \
418 name: upload-review-docs
420 - build-html-and-pdf-docs-output
421 - upload-under-review-docs-to-opnfv-artifacts
422 - report-build-result-to-gerrit
425 name: upload-merged-docs
427 - build-html-and-pdf-docs-output
428 - upload-generated-docs-to-opnfv-artifacts
429 - report-build-result-to-gerrit
430 - remove-old-docs-from-opnfv-artifacts
433 name: check-bash-syntax
435 - shell: "find . -name '*.sh' | xargs bash -n"
445 export PATH=$PATH:/usr/local/bin/
447 # install python packages
448 pip install "yamllint==1.6.0"
450 # generate and upload lint log
451 echo "Running yaml code on $PROJECT ..."
453 # Ensure we start with a clean environment
454 rm -f yaml-violation.log lint.log
456 # Get number of yaml violations. If none, this will be an
459 -type f -name "*.yml" -print \
460 -o -name "*.yaml" -print | \
461 xargs yamllint > yaml-violation.log || true
463 if [ -s "yaml-violation.log" ]; then
464 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
465 echo -e "First $SHOWN shown\n---" > lint.log
466 cat yaml-violation.log >> lint.log
467 sed -r -i '4,$s/^/ /g' lint.log
471 name: clean-workspace
478 sudo /bin/rm -rf "$WORKSPACE"
481 name: clean-workspace-log
484 find $WORKSPACE -type f -name '*.log' | xargs rm -f
487 name: archive-artifacts
490 artifacts: '{artifacts}'
496 name: publish-coverage
499 report-file: "coverage.xml"
501 health-auto-update: "false"
502 stability-auto-update: "false"
503 zoom-coverage-chart: "true"
514 # The majority of the email-ext plugin options are set to the default
515 # for this macro so they can be managed through Jenkins' global
518 name: email-jenkins-admins-on-failure
522 attach-build-log: true