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'
137 name: ssh-agent-wrapper
139 - ssh-agent-credentials:
141 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
144 name: build-html-and-pdf-docs-output
150 export PATH=$PATH:/usr/local/bin/
151 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
152 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
155 name: upload-under-review-docs-to-opnfv-artifacts
162 export PATH=$PATH:/usr/local/bin/
164 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
165 [[ -d docs_output ]] || exit 0
168 echo "###########################"
169 echo "UPLOADING DOCS UNDER REVIEW"
170 echo "###########################"
173 gs_base="artifacts.opnfv.org/$PROJECT/review"
174 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
175 local_path="upload/$GERRIT_CHANGE_NUMBER"
178 mv docs_output "$local_path"
179 gsutil -m cp -r "$local_path" "gs://$gs_base"
182 -h "Content-Type:text/html" \
183 -h "Cache-Control:private, max-age=0, no-transform" \
184 "gs://$gs_path"/**.html > /dev/null 2>&1
186 echo "Document link(s):" >> gerrit_comment.txt
187 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
188 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
191 name: upload-generated-docs-to-opnfv-artifacts
198 export PATH=$PATH:/usr/local/bin/
200 [[ -d docs_output ]] || exit 0
203 echo "########################"
204 echo "UPLOADING GENERATED DOCS"
205 echo "########################"
208 echo "gs_path="$GS_URL/docs""
209 echo "local_path="upload/docs""
211 gs_path="$GS_URL/docs"
212 local_path="upload/docs"
215 mv docs_output "$local_path"
218 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
219 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
222 -h "Content-Type:text/html" \
223 -h "Cache-Control:private, max-age=0, no-transform" \
224 "gs://$gs_path"/**.html > /dev/null 2>&1
226 echo "Document link(s):" >> gerrit_comment.txt
227 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
228 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
231 name: report-docs-build-result-to-gerrit
238 export PATH=$PATH:/usr/local/bin/
239 if [[ -e gerrit_comment.txt ]] ; then
241 echo "posting review comment to gerrit..."
243 cat gerrit_comment.txt
245 ssh -p 29418 gerrit.opnfv.org \
246 "gerrit review -p $GERRIT_PROJECT \
247 -m '$(cat gerrit_comment.txt)' \
248 $GERRIT_PATCHSET_REVISION \
253 name: remove-old-docs-from-opnfv-artifacts
260 export PATH=$PATH:/usr/local/bin/
262 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
264 gs_path="artifacts.opnfv.org/$PROJECT/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"
271 gs_path="artifacts.opnfv.org/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"
280 name: build-and-upload-artifacts-json-api
286 export PATH=$PATH:/usr/local/bin/
288 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
289 source $WORKSPACE/releng_artifacts/bin/activate
291 # install python packages
292 pip install google-api-python-client
294 # generate and upload index file
295 echo "Generating Artifacts API ..."
296 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
297 gsutil cp index.json gs://artifacts.opnfv.org/index.json
302 name: lint-python-code
309 export PATH=$PATH:/usr/local/bin/
311 virtualenv -p python2.7 $WORKSPACE/releng_flake8
312 source $WORKSPACE/releng_flake8/bin/activate
314 # install python packages
315 pip install "flake8==2.6.2"
317 # generate and upload lint log
318 echo "Running flake8 code on $PROJECT ..."
320 # Get number of flake8 violations. If none, this will be an
322 FLAKE_COUNT="$(find . \
323 -path './releng_flake8' -prune -o \
324 -path './.tox' -prune -o \
325 -type f -name "*.py" -print | \
326 xargs flake8 --exit-zero -qq --count 2>&1)"
328 # Ensure we start with a clean environment
331 if [ ! -z $FLAKE_COUNT ]; then
332 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
334 -path './releng_flake8' -prune -o \
335 -path './.tox' -prune -o \
336 -type f -name "*.py" -print | \
337 xargs flake8 --exit-zero --first >> violation.log
338 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
339 echo -e "First $SHOWN shown\n---" >> lint.log
340 cat violation.log >> lint.log
341 sed -r -i '4,$s/^/ /g' lint.log
348 name: report-lint-result-to-gerrit
355 export PATH=$PATH:/usr/local/bin/
357 # If no violations were found, no lint log will exist.
358 if [[ -e lint.log ]] ; then
359 echo -e "\nposting linting report to gerrit...\n"
364 ssh -p 29418 gerrit.opnfv.org \
365 "gerrit review -p $GERRIT_PROJECT \
366 -m \"$(cat lint.log)\" \
367 $GERRIT_PATCHSET_REVISION \
374 name: upload-review-docs
376 - build-html-and-pdf-docs-output
377 - upload-under-review-docs-to-opnfv-artifacts
378 - report-docs-build-result-to-gerrit
381 name: upload-merged-docs
383 - build-html-and-pdf-docs-output
384 - upload-generated-docs-to-opnfv-artifacts
385 - report-docs-build-result-to-gerrit
386 - remove-old-docs-from-opnfv-artifacts
389 name: check-bash-syntax
391 - shell: "find . -name '*.sh' | xargs bash -n"
401 export PATH=$PATH:/usr/local/bin/
403 # install python packages
404 pip install "yamllint==1.6.0"
406 # generate and upload lint log
407 echo "Running yaml code on $PROJECT ..."
409 # Ensure we start with a clean environment
410 rm -f yaml-violation.log lint.log
412 # Get number of yaml violations. If none, this will be an
415 -type f -name "*.yml" -print \
416 -o -name "*.yaml" -print | \
417 xargs yamllint > yaml-violation.log || true
419 if [ -s "yaml-violation.log" ]; then
420 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
421 echo -e "First $SHOWN shown\n---" > lint.log
422 cat yaml-violation.log >> lint.log
423 sed -r -i '4,$s/^/ /g' lint.log
427 name: archive-artifacts
430 artifacts: '{artifacts}'