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}'
139 server-name: 'gerrit.opnfv.org'
141 - comment-added-contains-event:
142 comment-contains-value: 'check-experimental'
144 - project-compare-type: 'ANT'
145 project-pattern: '{project}'
147 - branch-compare-type: 'ANT'
148 branch-pattern: '**/{branch}'
150 - compare-type: 'ANT'
159 name: ssh-agent-wrapper
161 - ssh-agent-credentials:
163 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
166 name: build-html-and-pdf-docs-output
172 export PATH=$PATH:/usr/local/bin/
173 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
174 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
177 name: upload-under-review-docs-to-opnfv-artifacts
184 export PATH=$PATH:/usr/local/bin/
186 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
187 [[ -d docs_output ]] || exit 0
190 echo "###########################"
191 echo "UPLOADING DOCS UNDER REVIEW"
192 echo "###########################"
195 gs_base="artifacts.opnfv.org/$PROJECT/review"
196 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
197 local_path="upload/$GERRIT_CHANGE_NUMBER"
200 mv docs_output "$local_path"
201 gsutil -m cp -r "$local_path" "gs://$gs_base"
204 -h "Content-Type:text/html" \
205 -h "Cache-Control:private, max-age=0, no-transform" \
206 "gs://$gs_path"/**.html > /dev/null 2>&1
208 echo "Document link(s):" >> gerrit_comment.txt
209 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
210 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
213 name: upload-generated-docs-to-opnfv-artifacts
220 export PATH=$PATH:/usr/local/bin/
222 [[ -d docs_output ]] || exit 0
225 echo "########################"
226 echo "UPLOADING GENERATED DOCS"
227 echo "########################"
230 echo "gs_path="$GS_URL/docs""
231 echo "local_path="upload/docs""
233 gs_path="$GS_URL/docs"
234 local_path="upload/docs"
237 mv docs_output "$local_path"
240 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
241 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
244 -h "Content-Type:text/html" \
245 -h "Cache-Control:private, max-age=0, no-transform" \
246 "gs://$gs_path"/**.html > /dev/null 2>&1
248 echo "Document link(s):" >> gerrit_comment.txt
249 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
250 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
253 name: report-docs-build-result-to-gerrit
260 export PATH=$PATH:/usr/local/bin/
261 if [[ -e gerrit_comment.txt ]] ; then
263 echo "posting review comment to gerrit..."
265 cat gerrit_comment.txt
267 ssh -p 29418 gerrit.opnfv.org \
268 "gerrit review -p $GERRIT_PROJECT \
269 -m '$(cat gerrit_comment.txt)' \
270 $GERRIT_PATCHSET_REVISION \
275 name: remove-old-docs-from-opnfv-artifacts
282 export PATH=$PATH:/usr/local/bin/
284 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
286 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
288 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
290 echo "Deleting Out-of-dated Documents..."
291 gsutil -m rm -r "gs://$gs_path"
293 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
295 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
297 echo "Deleting Out-of-dated Documents..."
298 gsutil -m rm -r "gs://$gs_path"
302 name: build-and-upload-artifacts-json-api
308 export PATH=$PATH:/usr/local/bin/
310 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
311 source $WORKSPACE/releng_artifacts/bin/activate
313 # install python packages
314 pip install google-api-python-client
316 # generate and upload index file
317 echo "Generating Artifacts API ..."
318 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
319 gsutil cp index.json gs://artifacts.opnfv.org/index.json
324 name: lint-python-code
331 export PATH=$PATH:/usr/local/bin/
333 virtualenv -p python2.7 $WORKSPACE/releng_flake8
334 source $WORKSPACE/releng_flake8/bin/activate
336 # install python packages
337 pip install "flake8==2.6.2"
339 # generate and upload lint log
340 echo "Running flake8 code on $PROJECT ..."
342 # Get number of flake8 violations. If none, this will be an
344 FLAKE_COUNT="$(find . \
345 -path './releng_flake8' -prune -o \
346 -path './.tox' -prune -o \
347 -type f -name "*.py" -print | \
348 xargs flake8 --exit-zero -qq --count 2>&1)"
350 # Ensure we start with a clean environment
353 if [ ! -z $FLAKE_COUNT ]; then
354 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
356 -path './releng_flake8' -prune -o \
357 -path './.tox' -prune -o \
358 -type f -name "*.py" -print | \
359 xargs flake8 --exit-zero --first >> violation.log
360 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
361 echo -e "First $SHOWN shown\n---" >> lint.log
362 cat violation.log >> lint.log
363 sed -r -i '4,$s/^/ /g' lint.log
370 name: report-lint-result-to-gerrit
377 export PATH=$PATH:/usr/local/bin/
379 # If no violations were found, no lint log will exist.
380 if [[ -e lint.log ]] ; then
381 echo -e "\nposting linting report to gerrit...\n"
386 ssh -p 29418 gerrit.opnfv.org \
387 "gerrit review -p $GERRIT_PROJECT \
388 -m \"$(cat lint.log)\" \
389 $GERRIT_PATCHSET_REVISION \
396 name: upload-review-docs
398 - build-html-and-pdf-docs-output
399 - upload-under-review-docs-to-opnfv-artifacts
400 - report-docs-build-result-to-gerrit
403 name: upload-merged-docs
405 - build-html-and-pdf-docs-output
406 - upload-generated-docs-to-opnfv-artifacts
407 - report-docs-build-result-to-gerrit
408 - remove-old-docs-from-opnfv-artifacts
411 name: check-bash-syntax
413 - shell: "find . -name '*.sh' | xargs bash -n"
423 export PATH=$PATH:/usr/local/bin/
425 # install python packages
426 pip install "yamllint==1.6.0"
428 # generate and upload lint log
429 echo "Running yaml code on $PROJECT ..."
431 # Ensure we start with a clean environment
432 rm -f yaml-violation.log lint.log
434 # Get number of yaml violations. If none, this will be an
437 -type f -name "*.yml" -print \
438 -o -name "*.yaml" -print | \
439 xargs yamllint > yaml-violation.log || true
441 if [ -s "yaml-violation.log" ]; then
442 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
443 echo -e "First $SHOWN shown\n---" > lint.log
444 cat yaml-violation.log >> lint.log
445 sed -r -i '4,$s/^/ /g' lint.log
449 name: clean-workspace-log
452 find $WORKSPACE -type f -name '*.log' | xargs rm -f
455 name: archive-artifacts
458 artifacts: '{artifacts}'
464 name: publish-coverage
467 report-file: "coverage.xml"
469 health-auto-update: "true"
470 stability-auto-update: "true"
471 zoom-coverage-chart: "true"