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}'
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'
169 name: build-html-and-pdf-docs-output
175 export PATH=$PATH:/usr/local/bin/
176 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
177 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
180 name: upload-under-review-docs-to-opnfv-artifacts
187 export PATH=$PATH:/usr/local/bin/
189 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
190 [[ -d docs_output ]] || exit 0
193 echo "###########################"
194 echo "UPLOADING DOCS UNDER REVIEW"
195 echo "###########################"
198 gs_base="artifacts.opnfv.org/$PROJECT/review"
199 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
200 local_path="upload/$GERRIT_CHANGE_NUMBER"
203 mv docs_output "$local_path"
204 gsutil -m cp -r "$local_path" "gs://$gs_base"
207 -h "Content-Type:text/html" \
208 -h "Cache-Control:private, max-age=0, no-transform" \
209 "gs://$gs_path"/**.html > /dev/null 2>&1
211 echo "Document link(s):" >> gerrit_comment.txt
212 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
213 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
216 name: upload-generated-docs-to-opnfv-artifacts
223 export PATH=$PATH:/usr/local/bin/
225 [[ -d docs_output ]] || exit 0
228 echo "########################"
229 echo "UPLOADING GENERATED DOCS"
230 echo "########################"
233 echo "gs_path="$GS_URL/docs""
234 echo "local_path="upload/docs""
236 gs_path="$GS_URL/docs"
237 local_path="upload/docs"
240 mv docs_output "$local_path"
243 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
244 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
247 -h "Content-Type:text/html" \
248 -h "Cache-Control:private, max-age=0, no-transform" \
249 "gs://$gs_path"/**.html > /dev/null 2>&1
251 echo "Document link(s):" >> gerrit_comment.txt
252 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
253 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
256 name: report-docs-build-result-to-gerrit
263 export PATH=$PATH:/usr/local/bin/
264 if [[ -e gerrit_comment.txt ]] ; then
266 echo "posting review comment to gerrit..."
268 cat gerrit_comment.txt
270 ssh -p 29418 gerrit.opnfv.org \
271 "gerrit review -p $GERRIT_PROJECT \
272 -m '$(cat gerrit_comment.txt)' \
273 $GERRIT_PATCHSET_REVISION \
278 name: remove-old-docs-from-opnfv-artifacts
285 export PATH=$PATH:/usr/local/bin/
287 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
289 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
291 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
293 echo "Deleting Out-of-dated Documents..."
294 gsutil -m rm -r "gs://$gs_path"
296 gs_path="artifacts.opnfv.org/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"
305 name: build-and-upload-artifacts-json-api
311 export PATH=$PATH:/usr/local/bin/
313 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
314 source $WORKSPACE/releng_artifacts/bin/activate
316 # install python packages
317 pip install google-api-python-client
319 # generate and upload index file
320 echo "Generating Artifacts API ..."
321 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
322 gsutil cp index.json gs://artifacts.opnfv.org/index.json
327 name: lint-python-code
334 export PATH=$PATH:/usr/local/bin/
336 virtualenv -p python2.7 $WORKSPACE/releng_flake8
337 source $WORKSPACE/releng_flake8/bin/activate
339 # install python packages
340 pip install "flake8==2.6.2"
342 # generate and upload lint log
343 echo "Running flake8 code on $PROJECT ..."
345 # Get number of flake8 violations. If none, this will be an
347 FLAKE_COUNT="$(find . \
348 -path './releng_flake8' -prune -o \
349 -path './.tox' -prune -o \
350 -type f -name "*.py" -print | \
351 xargs flake8 --exit-zero -qq --count 2>&1)"
353 # Ensure we start with a clean environment
356 if [ ! -z $FLAKE_COUNT ]; then
357 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
359 -path './releng_flake8' -prune -o \
360 -path './.tox' -prune -o \
361 -type f -name "*.py" -print | \
362 xargs flake8 --exit-zero --first >> violation.log
363 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
364 echo -e "First $SHOWN shown\n---" >> lint.log
365 cat violation.log >> lint.log
366 sed -r -i '4,$s/^/ /g' lint.log
373 name: report-lint-result-to-gerrit
380 export PATH=$PATH:/usr/local/bin/
382 # If no violations were found, no lint log will exist.
383 if [[ -e lint.log ]] ; then
384 echo -e "\nposting linting report to gerrit...\n"
389 ssh -p 29418 gerrit.opnfv.org \
390 "gerrit review -p $GERRIT_PROJECT \
391 -m \"$(cat lint.log)\" \
392 $GERRIT_PATCHSET_REVISION \
399 name: upload-review-docs
401 - build-html-and-pdf-docs-output
402 - upload-under-review-docs-to-opnfv-artifacts
403 - report-docs-build-result-to-gerrit
406 name: upload-merged-docs
408 - build-html-and-pdf-docs-output
409 - upload-generated-docs-to-opnfv-artifacts
410 - report-docs-build-result-to-gerrit
411 - remove-old-docs-from-opnfv-artifacts
414 name: check-bash-syntax
416 - shell: "find . -name '*.sh' | xargs bash -n"
426 export PATH=$PATH:/usr/local/bin/
428 # install python packages
429 pip install "yamllint==1.6.0"
431 # generate and upload lint log
432 echo "Running yaml code on $PROJECT ..."
434 # Ensure we start with a clean environment
435 rm -f yaml-violation.log lint.log
437 # Get number of yaml violations. If none, this will be an
440 -type f -name "*.yml" -print \
441 -o -name "*.yaml" -print | \
442 xargs yamllint > yaml-violation.log || true
444 if [ -s "yaml-violation.log" ]; then
445 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
446 echo -e "First $SHOWN shown\n---" > lint.log
447 cat yaml-violation.log >> lint.log
448 sed -r -i '4,$s/^/ /g' lint.log
452 name: clean-workspace-log
455 find $WORKSPACE -type f -name '*.log' | xargs rm -f
458 name: archive-artifacts
461 artifacts: '{artifacts}'
467 name: publish-coverage
470 report-file: "coverage.xml"
472 health-auto-update: "false"
473 stability-auto-update: "false"
474 zoom-coverage-chart: "true"