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"
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'
54 - 'origin/$GERRIT_BRANCH'
61 choosing-strategy: 'gerrit'
62 refspec: '$GERRIT_REFSPEC'
66 name: 'daily-trigger-disabled'
70 # NOTE: unused macro, but we may use this for some jobs.
72 name: gerrit-trigger-patch-submitted
75 server-name: 'gerrit.opnfv.org'
77 - patchset-created-event:
78 exclude-drafts: 'false'
79 exclude-trivial-rebase: 'false'
80 exclude-no-code-change: 'false'
81 - draft-published-event
82 - comment-added-contains-event:
83 comment-contains-value: 'recheck'
85 - project-compare-type: 'ANT'
86 project-pattern: '{name}'
88 - branch-compare-type: 'ANT'
89 branch-pattern: '**/{branch}'
91 # NOTE: unused macro, but we may use this for some jobs.
93 name: gerrit-trigger-patch-merged
96 server-name: 'gerrit.opnfv.org'
99 - comment-added-contains-event:
100 comment-contains-value: 'remerge'
102 - project-compare-type: 'ANT'
103 project-pattern: '{name}'
105 - branch-compare-type: 'ANT'
106 branch-pattern: '**/{branch}'
112 server-name: 'gerrit.opnfv.org'
114 - comment-added-contains-event:
115 comment-contains-value: 'check-experimental'
117 - project-compare-type: 'ANT'
118 project-pattern: '{project}'
120 - branch-compare-type: 'ANT'
121 branch-pattern: '**/{branch}'
123 - compare-type: 'ANT'
133 name: ssh-agent-wrapper
135 - ssh-agent-credentials:
137 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
140 name: build-html-and-pdf-docs-output
146 export PATH=$PATH:/usr/local/bin/
147 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
148 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
151 name: upload-under-review-docs-to-opnfv-artifacts
158 export PATH=$PATH:/usr/local/bin/
160 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
161 [[ -d docs_output ]] || exit 0
164 echo "###########################"
165 echo "UPLOADING DOCS UNDER REVIEW"
166 echo "###########################"
169 gs_base="artifacts.opnfv.org/$PROJECT/review"
170 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
171 local_path="upload/$GERRIT_CHANGE_NUMBER"
174 mv docs_output "$local_path"
175 gsutil -m cp -r "$local_path" "gs://$gs_base"
178 -h "Content-Type:text/html" \
179 -h "Cache-Control:private, max-age=0, no-transform" \
180 "gs://$gs_path"/**.html > /dev/null 2>&1
182 echo "Document link(s):" >> gerrit_comment.txt
183 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
184 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
187 name: upload-generated-docs-to-opnfv-artifacts
194 export PATH=$PATH:/usr/local/bin/
196 [[ -d docs_output ]] || exit 0
199 echo "########################"
200 echo "UPLOADING GENERATED DOCS"
201 echo "########################"
204 echo "gs_path="$GS_URL/docs""
205 echo "local_path="upload/docs""
207 gs_path="$GS_URL/docs"
208 local_path="upload/docs"
211 mv docs_output "$local_path"
214 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
215 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
218 -h "Content-Type:text/html" \
219 -h "Cache-Control:private, max-age=0, no-transform" \
220 "gs://$gs_path"/**.html > /dev/null 2>&1
222 echo "Document link(s):" >> gerrit_comment.txt
223 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
224 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
227 name: report-docs-build-result-to-gerrit
234 export PATH=$PATH:/usr/local/bin/
235 if [[ -e gerrit_comment.txt ]] ; then
237 echo "posting review comment to gerrit..."
239 cat gerrit_comment.txt
241 ssh -p 29418 gerrit.opnfv.org \
242 "gerrit review -p $GERRIT_PROJECT \
243 -m '$(cat gerrit_comment.txt)' \
244 $GERRIT_PATCHSET_REVISION \
249 name: remove-old-docs-from-opnfv-artifacts
256 export PATH=$PATH:/usr/local/bin/
258 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
260 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
262 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
264 echo "Deleting Out-of-dated Documents..."
265 gsutil -m rm -r "gs://$gs_path"
267 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
269 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
271 echo "Deleting Out-of-dated Documents..."
272 gsutil -m rm -r "gs://$gs_path"
276 name: build-and-upload-artifacts-json-api
282 export PATH=$PATH:/usr/local/bin/
284 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
285 source $WORKSPACE/releng_artifacts/bin/activate
287 # install python packages
288 pip install google-api-python-client
290 # generate and upload index file
291 echo "Generating Artifacts API ..."
292 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
293 gsutil cp index.json gs://artifacts.opnfv.org/index.json
298 name: lint-python-code
305 export PATH=$PATH:/usr/local/bin/
307 virtualenv -p python2.7 $WORKSPACE/releng_flake8
308 source $WORKSPACE/releng_flake8/bin/activate
310 # install python packages
311 pip install "flake8==2.6.2"
313 # generate and upload lint log
314 echo "Running flake8 code on $PROJECT ..."
316 # Get number of flake8 violations. If none, this will be an
318 FLAKE_COUNT="$(find . \
319 -path './releng_flake8' -prune -o \
320 -path './.tox' -prune -o \
321 -type f -name "*.py" -print | \
322 xargs flake8 --exit-zero -qq --count 2>&1)"
324 # Ensure we start with a clean environment
327 if [ ! -z $FLAKE_COUNT ]; then
328 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
330 -path './releng_flake8' -prune -o \
331 -path './.tox' -prune -o \
332 -type f -name "*.py" -print | \
333 xargs flake8 --exit-zero --first >> violation.log
334 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
335 echo -e "First $SHOWN shown\n---" >> lint.log
336 cat violation.log >> lint.log
337 sed -r -i '4,$s/^/ /g' lint.log
344 name: report-lint-result-to-gerrit
351 export PATH=$PATH:/usr/local/bin/
353 # If no violations were found, no lint log will exist.
354 if [[ -e lint.log ]] ; then
355 echo -e "\nposting linting report to gerrit...\n"
360 ssh -p 29418 gerrit.opnfv.org \
361 "gerrit review -p $GERRIT_PROJECT \
362 -m \"$(cat lint.log)\" \
363 $GERRIT_PATCHSET_REVISION \
370 name: upload-review-docs
372 - build-html-and-pdf-docs-output
373 - upload-under-review-docs-to-opnfv-artifacts
374 - report-docs-build-result-to-gerrit
377 name: upload-merged-docs
379 - build-html-and-pdf-docs-output
380 - upload-generated-docs-to-opnfv-artifacts
381 - report-docs-build-result-to-gerrit
382 - remove-old-docs-from-opnfv-artifacts
385 name: check-bash-syntax
387 - shell: "find . -name '*.sh' | xargs bash -n"
397 export PATH=$PATH:/usr/local/bin/
399 # install python packages
400 pip install "yamllint==1.6.0"
402 # generate and upload lint log
403 echo "Running yaml code on $PROJECT ..."
405 # Ensure we start with a clean environment
406 rm -f yaml-violation.log lint.log
408 # Get number of yaml violations. If none, this will be an
411 -type f -name "*.yml" -print \
412 -o -name "*.yaml" -print | \
413 xargs yamllint > yaml-violation.log || true
415 if [ -s "yaml-violation.log" ]; then
416 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
417 echo -e "First $SHOWN shown\n---" > lint.log
418 cat yaml-violation.log >> lint.log
419 sed -r -i '4,$s/^/ /g' lint.log
423 name: archive-artifacts
426 artifacts: '{artifacts}'