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 $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
263 name: report-docs-build-result-to-gerrit
270 export PATH=$PATH:/usr/local/bin/
271 if [[ -e gerrit_comment.txt ]] ; then
273 echo "posting review comment to gerrit..."
275 cat gerrit_comment.txt
277 ssh -p 29418 gerrit.opnfv.org \
278 "gerrit review -p $GERRIT_PROJECT \
279 -m '$(cat gerrit_comment.txt)' \
280 $GERRIT_PATCHSET_REVISION \
285 name: remove-old-docs-from-opnfv-artifacts
292 export PATH=$PATH:/usr/local/bin/
294 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
296 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
298 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
300 echo "Deleting Out-of-dated Documents..."
301 gsutil -m rm -r "gs://$gs_path"
303 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
305 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
307 echo "Deleting Out-of-dated Documents..."
308 gsutil -m rm -r "gs://$gs_path"
312 name: build-and-upload-artifacts-json-api
318 export PATH=$PATH:/usr/local/bin/
320 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
321 source $WORKSPACE/releng_artifacts/bin/activate
323 # install python packages
324 pip install google-api-python-client
326 # generate and upload index file
327 echo "Generating Artifacts API ..."
328 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
329 gsutil cp index.json gs://artifacts.opnfv.org/index.json
334 name: lint-python-code
341 export PATH=$PATH:/usr/local/bin/
343 virtualenv -p python2.7 $WORKSPACE/releng_flake8
344 source $WORKSPACE/releng_flake8/bin/activate
346 # install python packages
347 pip install "flake8==2.6.2"
349 # generate and upload lint log
350 echo "Running flake8 code on $PROJECT ..."
352 # Get number of flake8 violations. If none, this will be an
354 FLAKE_COUNT="$(find . \
355 -path './releng_flake8' -prune -o \
356 -path './.tox' -prune -o \
357 -type f -name "*.py" -print | \
358 xargs flake8 --exit-zero -qq --count 2>&1)"
360 # Ensure we start with a clean environment
363 if [ ! -z $FLAKE_COUNT ]; then
364 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
366 -path './releng_flake8' -prune -o \
367 -path './.tox' -prune -o \
368 -type f -name "*.py" -print | \
369 xargs flake8 --exit-zero --first >> violation.log
370 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
371 echo -e "First $SHOWN shown\n---" >> lint.log
372 cat violation.log >> lint.log
373 sed -r -i '4,$s/^/ /g' lint.log
380 name: report-lint-result-to-gerrit
387 export PATH=$PATH:/usr/local/bin/
389 # If no violations were found, no lint log will exist.
390 if [[ -e lint.log ]] ; then
391 echo -e "\nposting linting report to gerrit...\n"
396 ssh -p 29418 gerrit.opnfv.org \
397 "gerrit review -p $GERRIT_PROJECT \
398 -m \"$(cat lint.log)\" \
399 $GERRIT_PATCHSET_REVISION \
406 name: upload-review-docs
408 - build-html-and-pdf-docs-output
409 - upload-under-review-docs-to-opnfv-artifacts
410 - report-docs-build-result-to-gerrit
413 name: upload-merged-docs
415 - build-html-and-pdf-docs-output
416 - upload-generated-docs-to-opnfv-artifacts
417 - report-docs-build-result-to-gerrit
418 - remove-old-docs-from-opnfv-artifacts
421 name: check-bash-syntax
423 - shell: "find . -name '*.sh' | xargs bash -n"
433 export PATH=$PATH:/usr/local/bin/
435 # install python packages
436 pip install "yamllint==1.6.0"
438 # generate and upload lint log
439 echo "Running yaml code on $PROJECT ..."
441 # Ensure we start with a clean environment
442 rm -f yaml-violation.log lint.log
444 # Get number of yaml violations. If none, this will be an
447 -type f -name "*.yml" -print \
448 -o -name "*.yaml" -print | \
449 xargs yamllint > yaml-violation.log || true
451 if [ -s "yaml-violation.log" ]; then
452 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
453 echo -e "First $SHOWN shown\n---" > lint.log
454 cat yaml-violation.log >> lint.log
455 sed -r -i '4,$s/^/ /g' lint.log
459 name: clean-workspace-log
462 find $WORKSPACE -type f -name '*.log' | xargs rm -f
465 name: archive-artifacts
468 artifacts: '{artifacts}'
474 name: publish-coverage
477 report-file: "coverage.xml"
479 health-auto-update: "false"
480 stability-auto-update: "false"
481 zoom-coverage-chart: "true"