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 default: 'refs/heads/{branch}'
41 description: "Default refspec needed for manually triggering."
44 # Reporting Deployment Results
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:
54 # - track-begin-timestamp
57 # - report-provision-result
59 # Note: The following string parameter must also exist, as they are used
60 # when reporting the provision result:
66 # most installers include these but you should verify first before
67 # adding the publisher, otherwise the deployment build may be marked
72 name: testapi-parameter
76 default: 'http://testresults.opnfv.org/test/api/v1'
77 description: "Default TestAPI URL, currently using v1"
79 name: INSTALLER_VERSION
81 description: "Installer release version"
83 name: UPSTREAM_JOB_NAME
85 description: "Parent job name in Jenkins"
87 name: UPSTREAM_BUILD_ID
89 description: "Parent job build_id in Jenkins"
92 name: logrotate-default
97 artifact-days-to-keep: 60
98 artifact-num-to-keep: 200
103 - git: &git-scm-defaults
104 credentials-id: 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
121 choosing-strategy: 'gerrit'
122 refspec: '$GERRIT_REFSPEC'
123 <<: *git-scm-defaults
126 name: git-scm-gerrit-with-submodules
129 choosing-strategy: 'gerrit'
130 refspec: '$GERRIT_REFSPEC'
134 <<: *git-scm-defaults
136 name: git-scm-with-submodules
139 credentials-id: 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
143 - 'refs/heads/{branch}'
152 name: git-scm-openstack
154 - git: &git-scm-openstack-defaults
163 name: 'daily-trigger-disabled'
168 name: 'weekly-trigger-disabled'
173 name: gerrit-trigger-patchset-created
176 server-name: 'gerrit.opnfv.org'
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'
188 - project-compare-type: 'ANT'
189 project-pattern: '{project}'
191 - branch-compare-type: 'ANT'
192 branch-pattern: '**/{branch}'
194 - compare-type: 'ANT'
203 name: gerrit-trigger-patchset-approved
206 server-name: 'gerrit.opnfv.org'
208 - comment-added-event:
209 approval-category: 'CRVW'
211 - comment-added-contains-event:
212 comment-contains-value: 'gate'
214 - project-compare-type: 'ANT'
215 project-pattern: '{project}'
217 - branch-compare-type: 'ANT'
218 branch-pattern: '**/{branch}'
220 - compare-type: 'ANT'
229 name: gerrit-trigger-change-merged
232 server-name: 'gerrit.opnfv.org'
234 - change-merged-event
235 - comment-added-contains-event:
236 comment-contains-value: 'remerge'
238 - project-compare-type: 'ANT'
239 project-pattern: '{project}'
241 - branch-compare-type: 'ANT'
242 branch-pattern: '**/{branch}'
244 - compare-type: 'ANT'
248 name: gerrit-trigger-tag-created
251 server-name: 'gerrit.opnfv.org'
255 - project-compare-type: 'ANT'
256 project-pattern: '{project}'
258 - branch-compare-type: 'ANT'
259 branch-pattern: 'refs/tags/**'
265 server-name: 'gerrit.opnfv.org'
267 - comment-added-contains-event:
268 comment-contains-value: 'check-experimental'
270 - project-compare-type: 'ANT'
271 project-pattern: '{project}'
273 - branch-compare-type: 'ANT'
274 branch-pattern: '**/{branch}'
276 - compare-type: 'ANT'
285 name: ssh-agent-wrapper
287 - ssh-agent-credentials:
289 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
296 timeout-var: 'BUILD_TIMEOUT'
300 name: fix-workspace-permissions
305 sudo chown -R $USER:$USER $WORKSPACE || exit 1
308 name: upload-under-review-docs-to-opnfv-artifacts
315 export PATH=$PATH:/usr/local/bin/
317 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
318 [[ -d docs/_build/ ]] || exit 0
321 echo "###########################"
322 echo "UPLOADING DOCS UNDER REVIEW"
323 echo "###########################"
326 gs_base="artifacts.opnfv.org/$PROJECT/review"
327 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
328 local_path="upload/$GERRIT_CHANGE_NUMBER"
331 mv docs/_build/html/ "$local_path"
332 gsutil -m cp -r "$local_path" "gs://$gs_base"
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
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
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.
347 name: report-build-result-to-gerrit
354 export PATH=$PATH:/usr/local/bin/
355 if [[ -e gerrit_comment.txt ]] ; then
357 echo "posting review comment to gerrit..."
359 cat gerrit_comment.txt
361 ssh -p 29418 gerrit.opnfv.org \
362 "gerrit review -p $GERRIT_PROJECT \
363 -m '$(cat gerrit_comment.txt)' \
364 $GERRIT_PATCHSET_REVISION \
369 name: remove-old-docs-from-opnfv-artifacts
376 export PATH=$PATH:/usr/local/bin/
378 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
380 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
382 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
384 echo "Deleting Out-of-dated Documents..."
385 gsutil -m rm -r "gs://$gs_path"
387 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
389 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
391 echo "Deleting Out-of-dated Documents..."
392 gsutil -m rm -r "gs://$gs_path"
396 name: upload-review-docs
398 - upload-under-review-docs-to-opnfv-artifacts
399 - report-build-result-to-gerrit
406 # Ensure we start with a clean environment
407 rm -f bash-violation.log python-violation.log yaml-violation.log violation.log
408 git --no-pager diff --diff-filter=MCRAT --name-only HEAD^1 > modified_files
415 if [[ -s violation.log ]]; then
417 echo "Reporting lint result...."
419 msg="Found syntax error and/or coding style violation(s) in the files modified by your patchset."
420 sed -i -e "1s#^#${msg}\n\n#" violation.log
421 cmd="gerrit review -p $GERRIT_PROJECT -m \"$(cat violation.log)\" $GERRIT_PATCHSET_REVISION --notify NONE"
422 ssh -p 29418 gerrit.opnfv.org "$cmd"
424 # Make sure the caller job failed
433 echo "Checking bash code..."
434 for f in $(egrep '\.sh$' modified_files)
436 bash -n "$f" 2>> bash-violation.log
438 if [[ -s bash-violation.log ]]; then
439 echo -e "Bash syntax error(s)\n---" >> violation.log
440 sed -e 's/^/ /g' bash-violation.log >> violation.log
444 name: lint-python-code
448 # Install python package
449 sudo -H pip install "flake8==2.6.2"
451 echo "Checking python code..."
452 for f in $(egrep '\.py$' modified_files)
454 flake8 "$f" >> python-violation.log
456 if [[ -s python-violation.log ]]; then
457 echo -e "Python violation(s)\n---" >> violation.log
458 sed -e 's/^/ /g' python-violation.log >> violation.log
466 # sudo Install python packages
467 sudo -H pip install "yamllint==1.8.2"
469 echo "Checking yaml file..."
470 for f in $(egrep '\.ya?ml$' modified_files)
472 yamllint "$f" >> yaml-violation.log
474 if [[ -s yaml-violation.log ]]; then
475 echo -e "YAML violation(s)\n---" >> violation.log
476 sed -e 's/^/ /g' yaml-violation.log >> violation.log
489 name: clean-workspace
496 sudo /bin/rm -rf "$WORKSPACE"
499 name: clean-workspace-log
502 find $WORKSPACE -type f -name '*.log' | xargs rm -f
505 name: track-begin-timestamp
508 echo "export TIMESTAMP_START="\'`date '+%Y-%m-%d %H:%M:%S.%3N'`\' > $WORKSPACE/installer_track.sh
511 name: archive-artifacts
514 artifacts: '{artifacts}'
520 name: publish-coverage
523 report-file: "coverage.xml"
525 health-auto-update: "false"
526 stability-auto-update: "false"
527 zoom-coverage-chart: "true"
538 # The majority of the email-ext plugin options are set to the default
539 # for this macro so they can be managed through Jenkins' global
542 name: email-jenkins-admins-on-failure
546 attach-build-log: true
554 name: 'report-provision-result'
563 echo "export PROVISION_RESULT=PASS" >> $WORKSPACE/installer_track.sh
564 echo "export INSTALLER=$INSTALLER_TYPE" >> $WORKSPACE/installer_track.sh
565 echo "export TIMESTAMP_END="\'`date '+%Y-%m-%d %H:%M:%S.%3N'`\' >> $WORKSPACE/installer_track.sh
567 !include-raw: installer-report.sh
568 mark-unstable-if-failed: true
579 echo "export PROVISION_RESULT=FAIL" >> $WORKSPACE/installer_track.sh
580 echo "export INSTALLER=$INSTALLER_TYPE" >> $WORKSPACE/installer_track.sh
581 echo "export TIMESTAMP_END="\'`date '+%Y-%m-%d %H:%M:%S.%3N'`\' >> $WORKSPACE/installer_track.sh
583 !include-raw: installer-report.sh
584 mark-unstable-if-failed: true