4 # NOTE: make sure macros are listed in execution ordered.
6 # 1. parameters/properties
10 # 5. prebuilders (maven only, configured like Builders)
11 # 6. builders (maven, freestyle, matrix, etc..)
12 # 7. postbuilders (maven only, configured like Builders)
13 # 8. publishers/reporters/notifications
16 name: project-parameter
21 description: "JJB configured PROJECT parameter to identify an opnfv Gerrit project"
24 default: artifacts.opnfv.org/$PROJECT
25 description: "URL to Google Storage."
28 default: build.opnfv.org/artifacts.opnfv.org/$PROJECT
29 description: "URL to Google Storage proxy"
33 description: "JJB configured BRANCH parameter (e.g. master, stable/danube)"
37 description: "JJB configured GERRIT_BRANCH parameter (deprecated)"
40 name: logrotate-default
45 artifact-days-to-keep: 60
46 artifact-num-to-keep: 200
51 - git: &git-scm-defaults
52 credentials-id: '$SSH_CREDENTIAL_ID'
62 choosing-strategy: 'gerrit'
63 refspec: '$GERRIT_REFSPEC'
66 name: git-scm-with-submodules
69 credentials-id: '$SSH_CREDENTIAL_ID'
73 - '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}'
135 - compare-type: 'ANT'
142 server-name: 'gerrit.opnfv.org'
144 - comment-added-contains-event:
145 comment-contains-value: 'check-experimental'
147 - project-compare-type: 'ANT'
148 project-pattern: '{project}'
150 - branch-compare-type: 'ANT'
151 branch-pattern: '**/{branch}'
153 - compare-type: 'ANT'
162 name: ssh-agent-wrapper
164 - ssh-agent-credentials:
166 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
173 timeout-var: 'BUILD_TIMEOUT'
177 name: fix-workspace-permissions
182 sudo chown -R $USER:$USER $WORKSPACE || exit 1
185 name: upload-under-review-docs-to-opnfv-artifacts
192 export PATH=$PATH:/usr/local/bin/
194 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
195 [[ -d docs_output ]] || exit 0
198 echo "###########################"
199 echo "UPLOADING DOCS UNDER REVIEW"
200 echo "###########################"
203 gs_base="artifacts.opnfv.org/$PROJECT/review"
204 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
205 local_path="upload/$GERRIT_CHANGE_NUMBER"
208 mv docs/_build/html/ "$local_path"
209 gsutil -m cp -r "$local_path" "gs://$gs_base"
212 -h "Content-Type:text/html" \
213 -h "Cache-Control:private, max-age=0, no-transform" \
214 "gs://$gs_path"/**.html > /dev/null 2>&1
216 echo "Document link(s):" >> gerrit_comment.txt
217 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
218 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
220 # To take advantage of this macro, have your build write
221 # out the file 'gerrit_comment.txt' with information to post
222 # back to gerrit and include this macro in the list of builders.
224 name: report-build-result-to-gerrit
231 export PATH=$PATH:/usr/local/bin/
232 if [[ -e gerrit_comment.txt ]] ; then
234 echo "posting review comment to gerrit..."
236 cat gerrit_comment.txt
238 ssh -p 29418 gerrit.opnfv.org \
239 "gerrit review -p $GERRIT_PROJECT \
240 -m '$(cat gerrit_comment.txt)' \
241 $GERRIT_PATCHSET_REVISION \
246 name: remove-old-docs-from-opnfv-artifacts
253 export PATH=$PATH:/usr/local/bin/
255 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
257 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
259 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
261 echo "Deleting Out-of-dated Documents..."
262 gsutil -m rm -r "gs://$gs_path"
264 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
266 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
268 echo "Deleting Out-of-dated Documents..."
269 gsutil -m rm -r "gs://$gs_path"
273 name: build-and-upload-artifacts-json-api
279 export PATH=$PATH:/usr/local/bin/
281 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
282 source $WORKSPACE/releng_artifacts/bin/activate
284 # install python packages
285 pip install google-api-python-client
287 # generate and upload index file
288 echo "Generating Artifacts API ..."
289 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
290 gsutil cp index.json gs://artifacts.opnfv.org/index.json
295 name: lint-python-code
302 export PATH=$PATH:/usr/local/bin/
304 virtualenv -p python2.7 $WORKSPACE/releng_flake8
305 source $WORKSPACE/releng_flake8/bin/activate
307 # install python packages
308 pip install "flake8==2.6.2"
310 # generate and upload lint log
311 echo "Running flake8 code on $PROJECT ..."
313 # Get number of flake8 violations. If none, this will be an
315 FLAKE_COUNT="$(find . \
316 -path './releng_flake8' -prune -o \
317 -path './.tox' -prune -o \
318 -type f -name "*.py" -print | \
319 xargs flake8 --exit-zero -qq --count 2>&1)"
321 # Ensure we start with a clean environment
324 if [ ! -z $FLAKE_COUNT ]; then
325 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
327 -path './releng_flake8' -prune -o \
328 -path './.tox' -prune -o \
329 -type f -name "*.py" -print | \
330 xargs flake8 --exit-zero --first >> violation.log
331 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
332 echo -e "First $SHOWN shown\n---" >> lint.log
333 cat violation.log >> lint.log
334 sed -r -i '4,$s/^/ /g' lint.log
341 name: report-lint-result-to-gerrit
348 export PATH=$PATH:/usr/local/bin/
350 # If no violations were found, no lint log will exist.
351 if [[ -e lint.log ]] ; then
352 echo -e "\nposting linting report to gerrit...\n"
357 ssh -p 29418 gerrit.opnfv.org \
358 "gerrit review -p $GERRIT_PROJECT \
359 -m \"$(cat lint.log)\" \
360 $GERRIT_PATCHSET_REVISION \
367 name: upload-review-docs
369 - upload-under-review-docs-to-opnfv-artifacts
370 - report-build-result-to-gerrit
373 name: check-bash-syntax
375 - shell: "find . -name '*.sh' | xargs bash -n"
385 export PATH=$PATH:/usr/local/bin/
387 # install python packages
388 pip install "yamllint==1.6.0"
390 # generate and upload lint log
391 echo "Running yaml code on $PROJECT ..."
393 # Ensure we start with a clean environment
394 rm -f yaml-violation.log lint.log
396 # Get number of yaml violations. If none, this will be an
399 -type f -name "*.yml" -print \
400 -o -name "*.yaml" -print | \
401 xargs yamllint > yaml-violation.log || true
403 if [ -s "yaml-violation.log" ]; then
404 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
405 echo -e "First $SHOWN shown\n---" > lint.log
406 cat yaml-violation.log >> lint.log
407 sed -r -i '4,$s/^/ /g' lint.log
411 name: clean-workspace
418 sudo /bin/rm -rf "$WORKSPACE"
421 name: clean-workspace-log
424 find $WORKSPACE -type f -name '*.log' | xargs rm -f
427 name: archive-artifacts
430 artifacts: '{artifacts}'
436 name: publish-coverage
439 report-file: "coverage.xml"
441 health-auto-update: "false"
442 stability-auto-update: "false"
443 zoom-coverage-chart: "true"
454 # The majority of the email-ext plugin options are set to the default
455 # for this macro so they can be managed through Jenkins' global
458 name: email-jenkins-admins-on-failure
462 attach-build-log: true