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: build-html-and-pdf-docs-output
174 export PATH=$PATH:/usr/local/bin/
175 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
176 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
179 name: upload-under-review-docs-to-opnfv-artifacts
186 export PATH=$PATH:/usr/local/bin/
188 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
189 [[ -d docs_output ]] || exit 0
192 echo "###########################"
193 echo "UPLOADING DOCS UNDER REVIEW"
194 echo "###########################"
197 gs_base="artifacts.opnfv.org/$PROJECT/review"
198 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
199 local_path="upload/$GERRIT_CHANGE_NUMBER"
202 mv docs_output "$local_path"
203 gsutil -m cp -r "$local_path" "gs://$gs_base"
206 -h "Content-Type:text/html" \
207 -h "Cache-Control:private, max-age=0, no-transform" \
208 "gs://$gs_path"/**.html > /dev/null 2>&1
210 echo "Document link(s):" >> gerrit_comment.txt
211 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
212 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
215 name: upload-generated-docs-to-opnfv-artifacts
222 export PATH=$PATH:/usr/local/bin/
224 [[ -d docs_output ]] || exit 0
227 echo "########################"
228 echo "UPLOADING GENERATED DOCS"
229 echo "########################"
232 echo "gs_path="$GS_URL/docs""
233 echo "local_path="upload/docs""
235 gs_path="$GS_URL/docs"
236 local_path="upload/docs"
239 mv docs_output "$local_path"
242 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
243 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
246 -h "Content-Type:text/html" \
247 -h "Cache-Control:private, max-age=0, no-transform" \
248 "gs://$gs_path"/**.html > /dev/null 2>&1
250 echo "Document link(s):" >> gerrit_comment.txt
251 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
252 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
255 name: report-docs-build-result-to-gerrit
262 export PATH=$PATH:/usr/local/bin/
263 if [[ -e gerrit_comment.txt ]] ; then
265 echo "posting review comment to gerrit..."
267 cat gerrit_comment.txt
269 ssh -p 29418 gerrit.opnfv.org \
270 "gerrit review -p $GERRIT_PROJECT \
271 -m '$(cat gerrit_comment.txt)' \
272 $GERRIT_PATCHSET_REVISION \
277 name: remove-old-docs-from-opnfv-artifacts
284 export PATH=$PATH:/usr/local/bin/
286 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
288 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
290 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
292 echo "Deleting Out-of-dated Documents..."
293 gsutil -m rm -r "gs://$gs_path"
295 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
297 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
299 echo "Deleting Out-of-dated Documents..."
300 gsutil -m rm -r "gs://$gs_path"
304 name: build-and-upload-artifacts-json-api
310 export PATH=$PATH:/usr/local/bin/
312 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
313 source $WORKSPACE/releng_artifacts/bin/activate
315 # install python packages
316 pip install google-api-python-client
318 # generate and upload index file
319 echo "Generating Artifacts API ..."
320 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
321 gsutil cp index.json gs://artifacts.opnfv.org/index.json
326 name: lint-python-code
333 export PATH=$PATH:/usr/local/bin/
335 virtualenv -p python2.7 $WORKSPACE/releng_flake8
336 source $WORKSPACE/releng_flake8/bin/activate
338 # install python packages
339 pip install "flake8==2.6.2"
341 # generate and upload lint log
342 echo "Running flake8 code on $PROJECT ..."
344 # Get number of flake8 violations. If none, this will be an
346 FLAKE_COUNT="$(find . \
347 -path './releng_flake8' -prune -o \
348 -path './.tox' -prune -o \
349 -type f -name "*.py" -print | \
350 xargs flake8 --exit-zero -qq --count 2>&1)"
352 # Ensure we start with a clean environment
355 if [ ! -z $FLAKE_COUNT ]; then
356 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
358 -path './releng_flake8' -prune -o \
359 -path './.tox' -prune -o \
360 -type f -name "*.py" -print | \
361 xargs flake8 --exit-zero --first >> violation.log
362 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
363 echo -e "First $SHOWN shown\n---" >> lint.log
364 cat violation.log >> lint.log
365 sed -r -i '4,$s/^/ /g' lint.log
372 name: report-lint-result-to-gerrit
379 export PATH=$PATH:/usr/local/bin/
381 # If no violations were found, no lint log will exist.
382 if [[ -e lint.log ]] ; then
383 echo -e "\nposting linting report to gerrit...\n"
388 ssh -p 29418 gerrit.opnfv.org \
389 "gerrit review -p $GERRIT_PROJECT \
390 -m \"$(cat lint.log)\" \
391 $GERRIT_PATCHSET_REVISION \
398 name: upload-review-docs
400 - build-html-and-pdf-docs-output
401 - upload-under-review-docs-to-opnfv-artifacts
402 - report-docs-build-result-to-gerrit
405 name: upload-merged-docs
407 - build-html-and-pdf-docs-output
408 - upload-generated-docs-to-opnfv-artifacts
409 - report-docs-build-result-to-gerrit
410 - remove-old-docs-from-opnfv-artifacts
413 name: check-bash-syntax
415 - shell: "find . -name '*.sh' | xargs bash -n"
425 export PATH=$PATH:/usr/local/bin/
427 # install python packages
428 pip install "yamllint==1.6.0"
430 # generate and upload lint log
431 echo "Running yaml code on $PROJECT ..."
433 # Ensure we start with a clean environment
434 rm -f yaml-violation.log lint.log
436 # Get number of yaml violations. If none, this will be an
439 -type f -name "*.yml" -print \
440 -o -name "*.yaml" -print | \
441 xargs yamllint > yaml-violation.log || true
443 if [ -s "yaml-violation.log" ]; then
444 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
445 echo -e "First $SHOWN shown\n---" > lint.log
446 cat yaml-violation.log >> lint.log
447 sed -r -i '4,$s/^/ /g' lint.log
451 name: clean-workspace-log
454 find $WORKSPACE -type f -name '*.log' | xargs rm -f
457 name: archive-artifacts
460 artifacts: '{artifacts}'
466 name: publish-coverage
469 report-file: "coverage.xml"
471 health-auto-update: "false"
472 stability-auto-update: "false"
473 zoom-coverage-chart: "true"