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'
100 - comment-added-contains-event:
101 comment-contains-value: 'reverify'
103 - project-compare-type: 'ANT'
104 project-pattern: '{project}'
106 - branch-compare-type: 'ANT'
107 branch-pattern: '**/{branch}'
109 - compare-type: 'ANT'
118 name: gerrit-trigger-change-merged
121 server-name: 'gerrit.opnfv.org'
123 - change-merged-event
124 - comment-added-contains-event:
125 comment-contains-value: 'remerge'
127 - project-compare-type: 'ANT'
128 project-pattern: '{project}'
130 - branch-compare-type: 'ANT'
131 branch-pattern: '**/{branch}'
137 server-name: 'gerrit.opnfv.org'
139 - comment-added-contains-event:
140 comment-contains-value: 'check-experimental'
142 - project-compare-type: 'ANT'
143 project-pattern: '{project}'
145 - branch-compare-type: 'ANT'
146 branch-pattern: '**/{branch}'
148 - compare-type: 'ANT'
157 name: ssh-agent-wrapper
159 - ssh-agent-credentials:
161 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
164 name: build-html-and-pdf-docs-output
170 export PATH=$PATH:/usr/local/bin/
171 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
172 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
175 name: upload-under-review-docs-to-opnfv-artifacts
182 export PATH=$PATH:/usr/local/bin/
184 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
185 [[ -d docs_output ]] || exit 0
188 echo "###########################"
189 echo "UPLOADING DOCS UNDER REVIEW"
190 echo "###########################"
193 gs_base="artifacts.opnfv.org/$PROJECT/review"
194 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
195 local_path="upload/$GERRIT_CHANGE_NUMBER"
198 mv docs_output "$local_path"
199 gsutil -m cp -r "$local_path" "gs://$gs_base"
202 -h "Content-Type:text/html" \
203 -h "Cache-Control:private, max-age=0, no-transform" \
204 "gs://$gs_path"/**.html > /dev/null 2>&1
206 echo "Document link(s):" >> gerrit_comment.txt
207 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
208 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
211 name: upload-generated-docs-to-opnfv-artifacts
218 export PATH=$PATH:/usr/local/bin/
220 [[ -d docs_output ]] || exit 0
223 echo "########################"
224 echo "UPLOADING GENERATED DOCS"
225 echo "########################"
228 echo "gs_path="$GS_URL/docs""
229 echo "local_path="upload/docs""
231 gs_path="$GS_URL/docs"
232 local_path="upload/docs"
235 mv docs_output "$local_path"
238 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
239 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
242 -h "Content-Type:text/html" \
243 -h "Cache-Control:private, max-age=0, no-transform" \
244 "gs://$gs_path"/**.html > /dev/null 2>&1
246 echo "Document link(s):" >> gerrit_comment.txt
247 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
248 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
251 name: report-docs-build-result-to-gerrit
258 export PATH=$PATH:/usr/local/bin/
259 if [[ -e gerrit_comment.txt ]] ; then
261 echo "posting review comment to gerrit..."
263 cat gerrit_comment.txt
265 ssh -p 29418 gerrit.opnfv.org \
266 "gerrit review -p $GERRIT_PROJECT \
267 -m '$(cat gerrit_comment.txt)' \
268 $GERRIT_PATCHSET_REVISION \
273 name: remove-old-docs-from-opnfv-artifacts
280 export PATH=$PATH:/usr/local/bin/
282 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
284 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
286 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
288 echo "Deleting Out-of-dated Documents..."
289 gsutil -m rm -r "gs://$gs_path"
291 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
293 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
295 echo "Deleting Out-of-dated Documents..."
296 gsutil -m rm -r "gs://$gs_path"
300 name: build-and-upload-artifacts-json-api
306 export PATH=$PATH:/usr/local/bin/
308 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
309 source $WORKSPACE/releng_artifacts/bin/activate
311 # install python packages
312 pip install google-api-python-client
314 # generate and upload index file
315 echo "Generating Artifacts API ..."
316 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
317 gsutil cp index.json gs://artifacts.opnfv.org/index.json
322 name: lint-python-code
329 export PATH=$PATH:/usr/local/bin/
331 virtualenv -p python2.7 $WORKSPACE/releng_flake8
332 source $WORKSPACE/releng_flake8/bin/activate
334 # install python packages
335 pip install "flake8==2.6.2"
337 # generate and upload lint log
338 echo "Running flake8 code on $PROJECT ..."
340 # Get number of flake8 violations. If none, this will be an
342 FLAKE_COUNT="$(find . \
343 -path './releng_flake8' -prune -o \
344 -path './.tox' -prune -o \
345 -type f -name "*.py" -print | \
346 xargs flake8 --exit-zero -qq --count 2>&1)"
348 # Ensure we start with a clean environment
351 if [ ! -z $FLAKE_COUNT ]; then
352 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
354 -path './releng_flake8' -prune -o \
355 -path './.tox' -prune -o \
356 -type f -name "*.py" -print | \
357 xargs flake8 --exit-zero --first >> violation.log
358 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
359 echo -e "First $SHOWN shown\n---" >> lint.log
360 cat violation.log >> lint.log
361 sed -r -i '4,$s/^/ /g' lint.log
368 name: report-lint-result-to-gerrit
375 export PATH=$PATH:/usr/local/bin/
377 # If no violations were found, no lint log will exist.
378 if [[ -e lint.log ]] ; then
379 echo -e "\nposting linting report to gerrit...\n"
384 ssh -p 29418 gerrit.opnfv.org \
385 "gerrit review -p $GERRIT_PROJECT \
386 -m \"$(cat lint.log)\" \
387 $GERRIT_PATCHSET_REVISION \
394 name: upload-review-docs
396 - build-html-and-pdf-docs-output
397 - upload-under-review-docs-to-opnfv-artifacts
398 - report-docs-build-result-to-gerrit
401 name: upload-merged-docs
403 - build-html-and-pdf-docs-output
404 - upload-generated-docs-to-opnfv-artifacts
405 - report-docs-build-result-to-gerrit
406 - remove-old-docs-from-opnfv-artifacts
409 name: check-bash-syntax
411 - shell: "find . -name '*.sh' | xargs bash -n"
421 export PATH=$PATH:/usr/local/bin/
423 # install python packages
424 pip install "yamllint==1.6.0"
426 # generate and upload lint log
427 echo "Running yaml code on $PROJECT ..."
429 # Ensure we start with a clean environment
430 rm -f yaml-violation.log lint.log
432 # Get number of yaml violations. If none, this will be an
435 -type f -name "*.yml" -print \
436 -o -name "*.yaml" -print | \
437 xargs yamllint > yaml-violation.log || true
439 if [ -s "yaml-violation.log" ]; then
440 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
441 echo -e "First $SHOWN shown\n---" > lint.log
442 cat yaml-violation.log >> lint.log
443 sed -r -i '4,$s/^/ /g' lint.log
447 name: clean-workspace-log
450 find $WORKSPACE -type f -name '*.log' | xargs rm -f
453 name: archive-artifacts
456 artifacts: '{artifacts}'