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}'
78 name: 'daily-trigger-disabled'
83 name: 'weekly-trigger-disabled'
88 name: gerrit-trigger-patchset-created
91 server-name: 'gerrit.opnfv.org'
93 - patchset-created-event:
94 exclude-drafts: 'false'
95 exclude-trivial-rebase: 'false'
96 exclude-no-code-change: 'false'
97 - draft-published-event
98 - comment-added-contains-event:
99 comment-contains-value: 'recheck'
101 - project-compare-type: 'ANT'
102 project-pattern: '{project}'
104 - branch-compare-type: 'ANT'
105 branch-pattern: '**/{branch}'
107 - compare-type: 'ANT'
116 name: gerrit-trigger-change-merged
119 server-name: 'gerrit.opnfv.org'
121 - change-merged-event
122 - comment-added-contains-event:
123 comment-contains-value: 'remerge'
125 - project-compare-type: 'ANT'
126 project-pattern: '{project}'
128 - branch-compare-type: 'ANT'
129 branch-pattern: '**/{branch}'
135 server-name: 'gerrit.opnfv.org'
137 - comment-added-contains-event:
138 comment-contains-value: 'check-experimental'
140 - project-compare-type: 'ANT'
141 project-pattern: '{project}'
143 - branch-compare-type: 'ANT'
144 branch-pattern: '**/{branch}'
146 - compare-type: 'ANT'
155 name: ssh-agent-wrapper
157 - ssh-agent-credentials:
159 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
162 name: build-html-and-pdf-docs-output
168 export PATH=$PATH:/usr/local/bin/
169 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
170 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
173 name: upload-under-review-docs-to-opnfv-artifacts
180 export PATH=$PATH:/usr/local/bin/
182 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
183 [[ -d docs_output ]] || exit 0
186 echo "###########################"
187 echo "UPLOADING DOCS UNDER REVIEW"
188 echo "###########################"
191 gs_base="artifacts.opnfv.org/$PROJECT/review"
192 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
193 local_path="upload/$GERRIT_CHANGE_NUMBER"
196 mv docs_output "$local_path"
197 gsutil -m cp -r "$local_path" "gs://$gs_base"
200 -h "Content-Type:text/html" \
201 -h "Cache-Control:private, max-age=0, no-transform" \
202 "gs://$gs_path"/**.html > /dev/null 2>&1
204 echo "Document link(s):" >> gerrit_comment.txt
205 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
206 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
209 name: upload-generated-docs-to-opnfv-artifacts
216 export PATH=$PATH:/usr/local/bin/
218 [[ -d docs_output ]] || exit 0
221 echo "########################"
222 echo "UPLOADING GENERATED DOCS"
223 echo "########################"
226 echo "gs_path="$GS_URL/docs""
227 echo "local_path="upload/docs""
229 gs_path="$GS_URL/docs"
230 local_path="upload/docs"
233 mv docs_output "$local_path"
236 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
237 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
240 -h "Content-Type:text/html" \
241 -h "Cache-Control:private, max-age=0, no-transform" \
242 "gs://$gs_path"/**.html > /dev/null 2>&1
244 echo "Document link(s):" >> gerrit_comment.txt
245 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
246 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
249 name: report-docs-build-result-to-gerrit
256 export PATH=$PATH:/usr/local/bin/
257 if [[ -e gerrit_comment.txt ]] ; then
259 echo "posting review comment to gerrit..."
261 cat gerrit_comment.txt
263 ssh -p 29418 gerrit.opnfv.org \
264 "gerrit review -p $GERRIT_PROJECT \
265 -m '$(cat gerrit_comment.txt)' \
266 $GERRIT_PATCHSET_REVISION \
271 name: remove-old-docs-from-opnfv-artifacts
278 export PATH=$PATH:/usr/local/bin/
280 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
282 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
284 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
286 echo "Deleting Out-of-dated Documents..."
287 gsutil -m rm -r "gs://$gs_path"
289 gs_path="artifacts.opnfv.org/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"
298 name: build-and-upload-artifacts-json-api
304 export PATH=$PATH:/usr/local/bin/
306 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
307 source $WORKSPACE/releng_artifacts/bin/activate
309 # install python packages
310 pip install google-api-python-client
312 # generate and upload index file
313 echo "Generating Artifacts API ..."
314 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
315 gsutil cp index.json gs://artifacts.opnfv.org/index.json
320 name: lint-python-code
327 export PATH=$PATH:/usr/local/bin/
329 virtualenv -p python2.7 $WORKSPACE/releng_flake8
330 source $WORKSPACE/releng_flake8/bin/activate
332 # install python packages
333 pip install "flake8==2.6.2"
335 # generate and upload lint log
336 echo "Running flake8 code on $PROJECT ..."
338 # Get number of flake8 violations. If none, this will be an
340 FLAKE_COUNT="$(find . \
341 -path './releng_flake8' -prune -o \
342 -path './.tox' -prune -o \
343 -type f -name "*.py" -print | \
344 xargs flake8 --exit-zero -qq --count 2>&1)"
346 # Ensure we start with a clean environment
349 if [ ! -z $FLAKE_COUNT ]; then
350 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
352 -path './releng_flake8' -prune -o \
353 -path './.tox' -prune -o \
354 -type f -name "*.py" -print | \
355 xargs flake8 --exit-zero --first >> violation.log
356 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
357 echo -e "First $SHOWN shown\n---" >> lint.log
358 cat violation.log >> lint.log
359 sed -r -i '4,$s/^/ /g' lint.log
366 name: report-lint-result-to-gerrit
373 export PATH=$PATH:/usr/local/bin/
375 # If no violations were found, no lint log will exist.
376 if [[ -e lint.log ]] ; then
377 echo -e "\nposting linting report to gerrit...\n"
382 ssh -p 29418 gerrit.opnfv.org \
383 "gerrit review -p $GERRIT_PROJECT \
384 -m \"$(cat lint.log)\" \
385 $GERRIT_PATCHSET_REVISION \
392 name: upload-review-docs
394 - build-html-and-pdf-docs-output
395 - upload-under-review-docs-to-opnfv-artifacts
396 - report-docs-build-result-to-gerrit
399 name: upload-merged-docs
401 - build-html-and-pdf-docs-output
402 - upload-generated-docs-to-opnfv-artifacts
403 - report-docs-build-result-to-gerrit
404 - remove-old-docs-from-opnfv-artifacts
407 name: check-bash-syntax
409 - shell: "find . -name '*.sh' | xargs bash -n"
419 export PATH=$PATH:/usr/local/bin/
421 # install python packages
422 pip install "yamllint==1.6.0"
424 # generate and upload lint log
425 echo "Running yaml code on $PROJECT ..."
427 # Ensure we start with a clean environment
428 rm -f yaml-violation.log lint.log
430 # Get number of yaml violations. If none, this will be an
433 -type f -name "*.yml" -print \
434 -o -name "*.yaml" -print | \
435 xargs yamllint > yaml-violation.log || true
437 if [ -s "yaml-violation.log" ]; then
438 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
439 echo -e "First $SHOWN shown\n---" > lint.log
440 cat yaml-violation.log >> lint.log
441 sed -r -i '4,$s/^/ /g' lint.log
445 name: clean-workspace-log
448 find $WORKSPACE -type f -name '*.log' | xargs rm -f
451 name: archive-artifacts
454 artifacts: '{artifacts}'