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"
31 name: gerrit-parameter
36 description: "JJB configured GERRIT_BRANCH parameter"
41 - git: &git-scm-defaults
42 credentials-id: '$SSH_CREDENTIAL_ID'
45 - 'origin/$GERRIT_BRANCH'
52 choosing-strategy: 'gerrit'
53 refspec: '$GERRIT_REFSPEC'
57 name: 'daily-trigger-disabled'
61 # NOTE: unused macro, but we may use this for some jobs.
63 name: gerrit-trigger-patch-submitted
66 server-name: 'gerrit.opnfv.org'
68 - patchset-created-event:
69 exclude-drafts: 'false'
70 exclude-trivial-rebase: 'false'
71 exclude-no-code-change: 'false'
72 - draft-published-event
73 - comment-added-contains-event:
74 comment-contains-value: 'recheck'
76 - project-compare-type: 'ANT'
77 project-pattern: '{name}'
79 - branch-compare-type: 'ANT'
80 branch-pattern: '**/{branch}'
82 # NOTE: unused macro, but we may use this for some jobs.
84 name: gerrit-trigger-patch-merged
87 server-name: 'gerrit.opnfv.org'
90 - comment-added-contains-event:
91 comment-contains-value: 'remerge'
93 - project-compare-type: 'ANT'
94 project-pattern: '{name}'
96 - branch-compare-type: 'ANT'
97 branch-pattern: '**/{branch}'
103 server-name: 'gerrit.opnfv.org'
105 - comment-added-contains-event:
106 comment-contains-value: 'check-experimental'
108 - project-compare-type: 'ANT'
109 project-pattern: '{project}'
111 - branch-compare-type: 'ANT'
112 branch-pattern: '**/{branch}'
114 - compare-type: 'ANT'
124 name: ssh-agent-wrapper
126 - ssh-agent-credentials:
128 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
131 name: build-html-and-pdf-docs-output
137 export PATH=$PATH:/usr/local/bin/
138 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
139 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
142 name: upload-under-review-docs-to-opnfv-artifacts
149 export PATH=$PATH:/usr/local/bin/
151 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
152 [[ -d docs_output ]] || exit 0
155 echo "###########################"
156 echo "UPLOADING DOCS UNDER REVIEW"
157 echo "###########################"
160 gs_base="artifacts.opnfv.org/$PROJECT/review"
161 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
162 local_path="upload/$GERRIT_CHANGE_NUMBER"
165 mv docs_output "$local_path"
166 gsutil -m cp -r "$local_path" "gs://$gs_base"
169 -h "Content-Type:text/html" \
170 -h "Cache-Control:private, max-age=0, no-transform" \
171 "gs://$gs_path"/**.html > /dev/null 2>&1
173 echo "Document link(s):" >> gerrit_comment.txt
174 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
175 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
178 name: upload-generated-docs-to-opnfv-artifacts
185 export PATH=$PATH:/usr/local/bin/
187 [[ -d docs_output ]] || exit 0
190 echo "########################"
191 echo "UPLOADING GENERATED DOCS"
192 echo "########################"
195 echo "gs_path="$GS_URL/docs""
196 echo "local_path="upload/docs""
198 gs_path="$GS_URL/docs"
199 local_path="upload/docs"
202 mv docs_output "$local_path"
205 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
206 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
209 -h "Content-Type:text/html" \
210 -h "Cache-Control:private, max-age=0, no-transform" \
211 "gs://$gs_path"/**.html > /dev/null 2>&1
213 echo "Document link(s):" >> gerrit_comment.txt
214 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
215 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
218 name: report-docs-build-result-to-gerrit
225 export PATH=$PATH:/usr/local/bin/
226 if [[ -e gerrit_comment.txt ]] ; then
228 echo "posting review comment to gerrit..."
230 cat gerrit_comment.txt
232 ssh -p 29418 gerrit.opnfv.org \
233 "gerrit review -p $GERRIT_PROJECT \
234 -m '$(cat gerrit_comment.txt)' \
235 $GERRIT_PATCHSET_REVISION \
240 name: remove-old-docs-from-opnfv-artifacts
247 export PATH=$PATH:/usr/local/bin/
249 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
251 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
253 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
255 echo "Deleting Out-of-dated Documents..."
256 gsutil -m rm -r "gs://$gs_path"
258 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
260 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
262 echo "Deleting Out-of-dated Documents..."
263 gsutil -m rm -r "gs://$gs_path"
267 name: build-and-upload-artifacts-json-api
273 export PATH=$PATH:/usr/local/bin/
275 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
276 source $WORKSPACE/releng_artifacts/bin/activate
278 # install python packages
279 pip install google-api-python-client
281 # generate and upload index file
282 echo "Generating Artifacts API ..."
283 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
284 gsutil cp index.json gs://artifacts.opnfv.org/index.json
289 name: lint-python-code
296 export PATH=$PATH:/usr/local/bin/
298 virtualenv -p python2.7 $WORKSPACE/releng_flake8
299 source $WORKSPACE/releng_flake8/bin/activate
301 # install python packages
302 pip install "flake8==2.6.2"
304 # generate and upload lint log
305 echo "Running flake8 code on $PROJECT ..."
307 # Get number of flake8 violations. If none, this will be an
309 FLAKE_COUNT="$(find . \
310 -path './releng_flake8' -prune -o \
311 -path './.tox' -prune -o \
312 -type f -name "*.py" -print | \
313 xargs flake8 --exit-zero -qq --count 2>&1)"
315 # Ensure we start with a clean environment
318 if [ ! -z $FLAKE_COUNT ]; then
319 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
321 -path './releng_flake8' -prune -o \
322 -path './.tox' -prune -o \
323 -type f -name "*.py" -print | \
324 xargs flake8 --exit-zero --first >> violation.log
325 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
326 echo -e "First $SHOWN shown\n---" >> lint.log
327 cat violation.log >> lint.log
328 sed -r -i '4,$s/^/ /g' lint.log
335 name: report-lint-result-to-gerrit
342 export PATH=$PATH:/usr/local/bin/
344 # If no violations were found, no lint log will exist.
345 if [[ -e lint.log ]] ; then
346 echo -e "\nposting linting report to gerrit...\n"
351 ssh -p 29418 gerrit.opnfv.org \
352 "gerrit review -p $GERRIT_PROJECT \
353 -m \"$(cat lint.log)\" \
354 $GERRIT_PATCHSET_REVISION \
361 name: upload-review-docs
363 - build-html-and-pdf-docs-output
364 - upload-under-review-docs-to-opnfv-artifacts
365 - report-docs-build-result-to-gerrit
368 name: upload-merged-docs
370 - build-html-and-pdf-docs-output
371 - upload-generated-docs-to-opnfv-artifacts
372 - report-docs-build-result-to-gerrit
373 - remove-old-docs-from-opnfv-artifacts
376 name: check-bash-syntax
378 - shell: "find . -name '*.sh' | xargs bash -n"
388 export PATH=$PATH:/usr/local/bin/
390 # install python packages
391 pip install "yamllint==1.6.0"
393 # generate and upload lint log
394 echo "Running yaml code on $PROJECT ..."
396 # Ensure we start with a clean environment
397 rm -f yaml-violation.log lint.log
399 # Get number of yaml violations. If none, this will be an
402 -type f -name "*.yml" -print \
403 -o -name "*.yaml" -print | \
404 xargs yamllint > yaml-violation.log || true
406 if [ -s "yaml-violation.log" ]; then
407 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
408 echo -e "First $SHOWN shown\n---" > lint.log
409 cat yaml-violation.log >> lint.log
410 sed -r -i '4,$s/^/ /g' lint.log
414 name: archive-artifacts
417 artifacts: '{artifacts}'