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'
66 name: 'daily-trigger-disabled'
71 name: 'weekly-trigger-disabled'
75 # NOTE: unused macro, but we may use this for some jobs.
77 name: gerrit-trigger-patchset-created
80 server-name: 'gerrit.opnfv.org'
82 - patchset-created-event:
83 exclude-drafts: 'false'
84 exclude-trivial-rebase: 'false'
85 exclude-no-code-change: 'false'
86 - draft-published-event
87 - comment-added-contains-event:
88 comment-contains-value: 'recheck'
90 - project-compare-type: 'ANT'
91 project-pattern: '{project}'
93 - branch-compare-type: 'ANT'
94 branch-pattern: '**/{branch}'
97 name: gerrit-trigger-change-merged
100 server-name: 'gerrit.opnfv.org'
102 - change-merged-event
103 - comment-added-contains-event:
104 comment-contains-value: 'remerge'
106 - project-compare-type: 'ANT'
107 project-pattern: '{project}'
109 - branch-compare-type: 'ANT'
110 branch-pattern: '**/{branch}'
116 server-name: 'gerrit.opnfv.org'
118 - comment-added-contains-event:
119 comment-contains-value: 'check-experimental'
121 - project-compare-type: 'ANT'
122 project-pattern: '{project}'
124 - branch-compare-type: 'ANT'
125 branch-pattern: '**/{branch}'
127 - compare-type: 'ANT'
136 name: ssh-agent-wrapper
138 - ssh-agent-credentials:
140 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
143 name: build-html-and-pdf-docs-output
149 export PATH=$PATH:/usr/local/bin/
150 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
151 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
154 name: upload-under-review-docs-to-opnfv-artifacts
161 export PATH=$PATH:/usr/local/bin/
163 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
164 [[ -d docs_output ]] || exit 0
167 echo "###########################"
168 echo "UPLOADING DOCS UNDER REVIEW"
169 echo "###########################"
172 gs_base="artifacts.opnfv.org/$PROJECT/review"
173 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
174 local_path="upload/$GERRIT_CHANGE_NUMBER"
177 mv docs_output "$local_path"
178 gsutil -m cp -r "$local_path" "gs://$gs_base"
181 -h "Content-Type:text/html" \
182 -h "Cache-Control:private, max-age=0, no-transform" \
183 "gs://$gs_path"/**.html > /dev/null 2>&1
185 echo "Document link(s):" >> gerrit_comment.txt
186 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
187 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
190 name: upload-generated-docs-to-opnfv-artifacts
197 export PATH=$PATH:/usr/local/bin/
199 [[ -d docs_output ]] || exit 0
202 echo "########################"
203 echo "UPLOADING GENERATED DOCS"
204 echo "########################"
207 echo "gs_path="$GS_URL/docs""
208 echo "local_path="upload/docs""
210 gs_path="$GS_URL/docs"
211 local_path="upload/docs"
214 mv docs_output "$local_path"
217 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
218 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
221 -h "Content-Type:text/html" \
222 -h "Cache-Control:private, max-age=0, no-transform" \
223 "gs://$gs_path"/**.html > /dev/null 2>&1
225 echo "Document link(s):" >> gerrit_comment.txt
226 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
227 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
230 name: report-docs-build-result-to-gerrit
237 export PATH=$PATH:/usr/local/bin/
238 if [[ -e gerrit_comment.txt ]] ; then
240 echo "posting review comment to gerrit..."
242 cat gerrit_comment.txt
244 ssh -p 29418 gerrit.opnfv.org \
245 "gerrit review -p $GERRIT_PROJECT \
246 -m '$(cat gerrit_comment.txt)' \
247 $GERRIT_PATCHSET_REVISION \
252 name: remove-old-docs-from-opnfv-artifacts
259 export PATH=$PATH:/usr/local/bin/
261 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
263 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
265 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
267 echo "Deleting Out-of-dated Documents..."
268 gsutil -m rm -r "gs://$gs_path"
270 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
272 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
274 echo "Deleting Out-of-dated Documents..."
275 gsutil -m rm -r "gs://$gs_path"
279 name: build-and-upload-artifacts-json-api
285 export PATH=$PATH:/usr/local/bin/
287 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
288 source $WORKSPACE/releng_artifacts/bin/activate
290 # install python packages
291 pip install google-api-python-client
293 # generate and upload index file
294 echo "Generating Artifacts API ..."
295 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
296 gsutil cp index.json gs://artifacts.opnfv.org/index.json
301 name: lint-python-code
308 export PATH=$PATH:/usr/local/bin/
310 virtualenv -p python2.7 $WORKSPACE/releng_flake8
311 source $WORKSPACE/releng_flake8/bin/activate
313 # install python packages
314 pip install "flake8==2.6.2"
316 # generate and upload lint log
317 echo "Running flake8 code on $PROJECT ..."
319 # Get number of flake8 violations. If none, this will be an
321 FLAKE_COUNT="$(find . \
322 -path './releng_flake8' -prune -o \
323 -path './.tox' -prune -o \
324 -type f -name "*.py" -print | \
325 xargs flake8 --exit-zero -qq --count 2>&1)"
327 # Ensure we start with a clean environment
330 if [ ! -z $FLAKE_COUNT ]; then
331 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
333 -path './releng_flake8' -prune -o \
334 -path './.tox' -prune -o \
335 -type f -name "*.py" -print | \
336 xargs flake8 --exit-zero --first >> violation.log
337 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
338 echo -e "First $SHOWN shown\n---" >> lint.log
339 cat violation.log >> lint.log
340 sed -r -i '4,$s/^/ /g' lint.log
347 name: report-lint-result-to-gerrit
354 export PATH=$PATH:/usr/local/bin/
356 # If no violations were found, no lint log will exist.
357 if [[ -e lint.log ]] ; then
358 echo -e "\nposting linting report to gerrit...\n"
363 ssh -p 29418 gerrit.opnfv.org \
364 "gerrit review -p $GERRIT_PROJECT \
365 -m \"$(cat lint.log)\" \
366 $GERRIT_PATCHSET_REVISION \
373 name: upload-review-docs
375 - build-html-and-pdf-docs-output
376 - upload-under-review-docs-to-opnfv-artifacts
377 - report-docs-build-result-to-gerrit
380 name: upload-merged-docs
382 - build-html-and-pdf-docs-output
383 - upload-generated-docs-to-opnfv-artifacts
384 - report-docs-build-result-to-gerrit
385 - remove-old-docs-from-opnfv-artifacts
388 name: check-bash-syntax
390 - shell: "find . -name '*.sh' | xargs bash -n"
400 export PATH=$PATH:/usr/local/bin/
402 # install python packages
403 pip install "yamllint==1.6.0"
405 # generate and upload lint log
406 echo "Running yaml code on $PROJECT ..."
408 # Ensure we start with a clean environment
409 rm -f yaml-violation.log lint.log
411 # Get number of yaml violations. If none, this will be an
414 -type f -name "*.yml" -print \
415 -o -name "*.yaml" -print | \
416 xargs yamllint > yaml-violation.log || true
418 if [ -s "yaml-violation.log" ]; then
419 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
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-log
429 find $WORKSPACE -type f -name '*.log' | xargs rm -f
432 name: archive-artifacts
435 artifacts: '{artifacts}'