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'
71 name: 'weekly-trigger-disabled'
75 # NOTE: unused macro, but we may use this for some jobs.
77 name: gerrit-trigger-patch-submitted
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: '{name}'
93 - branch-compare-type: 'ANT'
94 branch-pattern: '**/{branch}'
96 # NOTE: unused macro, but we may use this for some jobs.
98 name: gerrit-trigger-patch-merged
101 server-name: 'gerrit.opnfv.org'
103 - change-merged-event
104 - comment-added-contains-event:
105 comment-contains-value: 'remerge'
107 - project-compare-type: 'ANT'
108 project-pattern: '{name}'
110 - branch-compare-type: 'ANT'
111 branch-pattern: '**/{branch}'
117 server-name: 'gerrit.opnfv.org'
119 - comment-added-contains-event:
120 comment-contains-value: 'check-experimental'
122 - project-compare-type: 'ANT'
123 project-pattern: '{project}'
125 - branch-compare-type: 'ANT'
126 branch-pattern: '**/{branch}'
128 - compare-type: 'ANT'
138 name: ssh-agent-wrapper
140 - ssh-agent-credentials:
142 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
145 name: build-html-and-pdf-docs-output
151 export PATH=$PATH:/usr/local/bin/
152 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
153 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
156 name: upload-under-review-docs-to-opnfv-artifacts
163 export PATH=$PATH:/usr/local/bin/
165 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
166 [[ -d docs_output ]] || exit 0
169 echo "###########################"
170 echo "UPLOADING DOCS UNDER REVIEW"
171 echo "###########################"
174 gs_base="artifacts.opnfv.org/$PROJECT/review"
175 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
176 local_path="upload/$GERRIT_CHANGE_NUMBER"
179 mv docs_output "$local_path"
180 gsutil -m cp -r "$local_path" "gs://$gs_base"
183 -h "Content-Type:text/html" \
184 -h "Cache-Control:private, max-age=0, no-transform" \
185 "gs://$gs_path"/**.html > /dev/null 2>&1
187 echo "Document link(s):" >> gerrit_comment.txt
188 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
189 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
192 name: upload-generated-docs-to-opnfv-artifacts
199 export PATH=$PATH:/usr/local/bin/
201 [[ -d docs_output ]] || exit 0
204 echo "########################"
205 echo "UPLOADING GENERATED DOCS"
206 echo "########################"
209 echo "gs_path="$GS_URL/docs""
210 echo "local_path="upload/docs""
212 gs_path="$GS_URL/docs"
213 local_path="upload/docs"
216 mv docs_output "$local_path"
219 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
220 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
223 -h "Content-Type:text/html" \
224 -h "Cache-Control:private, max-age=0, no-transform" \
225 "gs://$gs_path"/**.html > /dev/null 2>&1
227 echo "Document link(s):" >> gerrit_comment.txt
228 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
229 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
232 name: report-docs-build-result-to-gerrit
239 export PATH=$PATH:/usr/local/bin/
240 if [[ -e gerrit_comment.txt ]] ; then
242 echo "posting review comment to gerrit..."
244 cat gerrit_comment.txt
246 ssh -p 29418 gerrit.opnfv.org \
247 "gerrit review -p $GERRIT_PROJECT \
248 -m '$(cat gerrit_comment.txt)' \
249 $GERRIT_PATCHSET_REVISION \
254 name: remove-old-docs-from-opnfv-artifacts
261 export PATH=$PATH:/usr/local/bin/
263 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
265 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
267 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
269 echo "Deleting Out-of-dated Documents..."
270 gsutil -m rm -r "gs://$gs_path"
272 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
274 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
276 echo "Deleting Out-of-dated Documents..."
277 gsutil -m rm -r "gs://$gs_path"
281 name: build-and-upload-artifacts-json-api
287 export PATH=$PATH:/usr/local/bin/
289 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
290 source $WORKSPACE/releng_artifacts/bin/activate
292 # install python packages
293 pip install google-api-python-client
295 # generate and upload index file
296 echo "Generating Artifacts API ..."
297 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
298 gsutil cp index.json gs://artifacts.opnfv.org/index.json
303 name: lint-python-code
310 export PATH=$PATH:/usr/local/bin/
312 virtualenv -p python2.7 $WORKSPACE/releng_flake8
313 source $WORKSPACE/releng_flake8/bin/activate
315 # install python packages
316 pip install "flake8==2.6.2"
318 # generate and upload lint log
319 echo "Running flake8 code on $PROJECT ..."
321 # Get number of flake8 violations. If none, this will be an
323 FLAKE_COUNT="$(find . \
324 -path './releng_flake8' -prune -o \
325 -path './.tox' -prune -o \
326 -type f -name "*.py" -print | \
327 xargs flake8 --exit-zero -qq --count 2>&1)"
329 # Ensure we start with a clean environment
332 if [ ! -z $FLAKE_COUNT ]; then
333 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
335 -path './releng_flake8' -prune -o \
336 -path './.tox' -prune -o \
337 -type f -name "*.py" -print | \
338 xargs flake8 --exit-zero --first >> violation.log
339 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
340 echo -e "First $SHOWN shown\n---" >> lint.log
341 cat violation.log >> lint.log
342 sed -r -i '4,$s/^/ /g' lint.log
349 name: report-lint-result-to-gerrit
356 export PATH=$PATH:/usr/local/bin/
358 # If no violations were found, no lint log will exist.
359 if [[ -e lint.log ]] ; then
360 echo -e "\nposting linting report to gerrit...\n"
365 ssh -p 29418 gerrit.opnfv.org \
366 "gerrit review -p $GERRIT_PROJECT \
367 -m \"$(cat lint.log)\" \
368 $GERRIT_PATCHSET_REVISION \
375 name: upload-review-docs
377 - build-html-and-pdf-docs-output
378 - upload-under-review-docs-to-opnfv-artifacts
379 - report-docs-build-result-to-gerrit
382 name: upload-merged-docs
384 - build-html-and-pdf-docs-output
385 - upload-generated-docs-to-opnfv-artifacts
386 - report-docs-build-result-to-gerrit
387 - remove-old-docs-from-opnfv-artifacts
390 name: check-bash-syntax
392 - shell: "find . -name '*.sh' | xargs bash -n"
402 export PATH=$PATH:/usr/local/bin/
404 # install python packages
405 pip install "yamllint==1.6.0"
407 # generate and upload lint log
408 echo "Running yaml code on $PROJECT ..."
410 # Ensure we start with a clean environment
411 rm -f yaml-violation.log lint.log
413 # Get number of yaml violations. If none, this will be an
416 -type f -name "*.yml" -print \
417 -o -name "*.yaml" -print | \
418 xargs yamllint > yaml-violation.log || true
420 if [ -s "yaml-violation.log" ]; then
421 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
422 echo -e "First $SHOWN shown\n---" > lint.log
423 cat yaml-violation.log >> lint.log
424 sed -r -i '4,$s/^/ /g' lint.log
428 name: archive-artifacts
431 artifacts: '{artifacts}'