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'
139 name: gerrit-trigger-tag-created
142 server-name: 'gerrit.opnfv.org'
146 - project-compare-type: 'ANT'
147 project-pattern: '{project}'
149 - branch-compare-type: 'ANT'
150 branch-pattern: 'refs/tags/**'
156 server-name: 'gerrit.opnfv.org'
158 - comment-added-contains-event:
159 comment-contains-value: 'check-experimental'
161 - project-compare-type: 'ANT'
162 project-pattern: '{project}'
164 - branch-compare-type: 'ANT'
165 branch-pattern: '**/{branch}'
167 - compare-type: 'ANT'
176 name: ssh-agent-wrapper
178 - ssh-agent-credentials:
180 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
187 timeout-var: 'BUILD_TIMEOUT'
191 name: fix-workspace-permissions
196 sudo chown -R $USER:$USER $WORKSPACE || exit 1
199 name: upload-under-review-docs-to-opnfv-artifacts
206 export PATH=$PATH:/usr/local/bin/
208 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
209 [[ -d docs/_build/ ]] || exit 0
212 echo "###########################"
213 echo "UPLOADING DOCS UNDER REVIEW"
214 echo "###########################"
217 gs_base="artifacts.opnfv.org/$PROJECT/review"
218 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
219 local_path="upload/$GERRIT_CHANGE_NUMBER"
222 mv docs/_build/html/ "$local_path"
223 gsutil -m cp -r "$local_path" "gs://$gs_base"
226 -h "Content-Type:text/html" \
227 -h "Cache-Control:private, max-age=0, no-transform" \
228 "gs://$gs_path"/**.html > /dev/null 2>&1
230 echo "Document link(s):" >> gerrit_comment.txt
231 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
232 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
234 # To take advantage of this macro, have your build write
235 # out the file 'gerrit_comment.txt' with information to post
236 # back to gerrit and include this macro in the list of builders.
238 name: report-build-result-to-gerrit
245 export PATH=$PATH:/usr/local/bin/
246 if [[ -e gerrit_comment.txt ]] ; then
248 echo "posting review comment to gerrit..."
250 cat gerrit_comment.txt
252 ssh -p 29418 gerrit.opnfv.org \
253 "gerrit review -p $GERRIT_PROJECT \
254 -m '$(cat gerrit_comment.txt)' \
255 $GERRIT_PATCHSET_REVISION \
260 name: remove-old-docs-from-opnfv-artifacts
267 export PATH=$PATH:/usr/local/bin/
269 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
271 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
273 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
275 echo "Deleting Out-of-dated Documents..."
276 gsutil -m rm -r "gs://$gs_path"
278 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
280 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
282 echo "Deleting Out-of-dated Documents..."
283 gsutil -m rm -r "gs://$gs_path"
287 name: build-and-upload-artifacts-json-api
293 export PATH=$PATH:/usr/local/bin/
295 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
296 source $WORKSPACE/releng_artifacts/bin/activate
298 # install python packages
299 pip install google-api-python-client
301 # generate and upload index file
302 echo "Generating Artifacts API ..."
303 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
304 gsutil cp index.json gs://artifacts.opnfv.org/index.json
309 name: lint-python-code
316 export PATH=$PATH:/usr/local/bin/
318 virtualenv -p python2.7 $WORKSPACE/releng_flake8
319 source $WORKSPACE/releng_flake8/bin/activate
321 # install python packages
322 pip install "flake8==2.6.2"
324 # generate and upload lint log
325 echo "Running flake8 code on $PROJECT ..."
327 # Get number of flake8 violations. If none, this will be an
329 FLAKE_COUNT="$(find . \
330 -path './releng_flake8' -prune -o \
331 -path './.tox' -prune -o \
332 -type f -name "*.py" -print | \
333 xargs flake8 --exit-zero -qq --count 2>&1)"
335 # Ensure we start with a clean environment
338 if [ ! -z $FLAKE_COUNT ]; then
339 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
341 -path './releng_flake8' -prune -o \
342 -path './.tox' -prune -o \
343 -type f -name "*.py" -print | \
344 xargs flake8 --exit-zero --first >> violation.log
345 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
346 echo -e "First $SHOWN shown\n---" >> lint.log
347 cat violation.log >> lint.log
348 sed -r -i '4,$s/^/ /g' lint.log
355 name: report-lint-result-to-gerrit
362 export PATH=$PATH:/usr/local/bin/
364 # If no violations were found, no lint log will exist.
365 if [[ -e lint.log ]] ; then
366 echo -e "\nposting linting report to gerrit...\n"
371 ssh -p 29418 gerrit.opnfv.org \
372 "gerrit review -p $GERRIT_PROJECT \
373 -m \"$(cat lint.log)\" \
374 $GERRIT_PATCHSET_REVISION \
381 name: upload-review-docs
383 - upload-under-review-docs-to-opnfv-artifacts
384 - report-build-result-to-gerrit
387 name: check-bash-syntax
389 - shell: "find . -name '*.sh' | xargs bash -n"
399 export PATH=$PATH:/usr/local/bin/
401 # install python packages
402 pip install "yamllint==1.6.0"
404 # generate and upload lint log
405 echo "Running yaml code on $PROJECT ..."
407 # Get list of yaml files
408 YAML_FILES=$(git --no-pager diff --diff-filter=MCRAT --name-only HEAD^1 | egrep "ya?ml$")
410 # Ensure we start with a clean environment
411 rm -f yaml-violation.log lint.log
413 # Yamllint files only in patchset
414 for yamlfile in $YAML_FILES; do
415 yamllint $yamlfile >> yaml-violation.log || true
418 if [ -s "yaml-violation.log" ]; then
419 SHOWN=$(grep -c -v "^$" yaml-violation.log)
420 echo -e "First $SHOWN shown\n---" > lint.log
421 cat yaml-violation.log >> lint.log
422 sed -r -i '4,$s/^/ /g' lint.log
426 name: clean-workspace
433 sudo /bin/rm -rf "$WORKSPACE"
436 name: clean-workspace-log
439 find $WORKSPACE -type f -name '*.log' | xargs rm -f
442 name: archive-artifacts
445 artifacts: '{artifacts}'
451 name: publish-coverage
454 report-file: "coverage.xml"
456 health-auto-update: "false"
457 stability-auto-update: "false"
458 zoom-coverage-chart: "true"
469 # The majority of the email-ext plugin options are set to the default
470 # for this macro so they can be managed through Jenkins' global
473 name: email-jenkins-admins-on-failure
477 attach-build-log: true