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"
41 - git: &git-scm-defaults
42 credentials-id: '$SSH_CREDENTIAL_ID'
45 - 'origin/$GERRIT_BRANCH'
52 choosing-strategy: 'gerrit'
53 refspec: '$GERRIT_REFSPEC'
57 name: 'daily-trigger-disabled'
61 # NOTE: unused macro, but we may use this for some jobs.
63 name: gerrit-trigger-patch-submitted
66 server-name: 'gerrit.opnfv.org'
68 - patchset-created-event:
69 exclude-drafts: 'false'
70 exclude-trivial-rebase: 'false'
71 exclude-no-code-change: 'false'
72 - draft-published-event
73 - comment-added-contains-event:
74 comment-contains-value: 'recheck'
76 - project-compare-type: 'ANT'
77 project-pattern: '{name}'
79 - branch-compare-type: 'ANT'
80 branch-pattern: '**/{branch}'
82 # NOTE: unused macro, but we may use this for some jobs.
84 name: gerrit-trigger-patch-merged
87 server-name: 'gerrit.opnfv.org'
90 - comment-added-contains-event:
91 comment-contains-value: 'remerge'
93 - project-compare-type: 'ANT'
94 project-pattern: '{name}'
96 - branch-compare-type: 'ANT'
97 branch-pattern: '**/{branch}'
100 name: ssh-agent-wrapper
102 - ssh-agent-credentials:
104 - 'd42411ac011ad6f3dd2e1fa34eaa5d87f910eb2e'
107 name: build-html-and-pdf-docs-output
113 export PATH=$PATH:/usr/local/bin/
114 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
115 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
118 name: upload-under-review-docs-to-opnfv-artifacts
125 export PATH=$PATH:/usr/local/bin/
127 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
128 [[ -d docs_output ]] || exit 0
131 echo "###########################"
132 echo "UPLOADING DOCS UNDER REVIEW"
133 echo "###########################"
136 gs_base="artifacts.opnfv.org/$PROJECT/review"
137 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
138 local_path="upload/$GERRIT_CHANGE_NUMBER"
141 mv docs_output "$local_path"
142 gsutil -m cp -r "$local_path" "gs://$gs_base"
145 -h "Content-Type:text/html" \
146 -h "Cache-Control:private, max-age=0, no-transform" \
147 "gs://$gs_path"/**.html > /dev/null 2>&1
149 echo "Document link(s):" >> gerrit_comment.txt
150 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
151 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
154 name: upload-generated-docs-to-opnfv-artifacts
161 export PATH=$PATH:/usr/local/bin/
163 [[ -d docs_output ]] || exit 0
166 echo "########################"
167 echo "UPLOADING GENERATED DOCS"
168 echo "########################"
171 echo "gs_path="$GS_URL/docs""
172 echo "local_path="upload/docs""
174 gs_path="$GS_URL/docs"
175 local_path="upload/docs"
178 mv docs_output "$local_path"
181 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
182 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
185 -h "Content-Type:text/html" \
186 -h "Cache-Control:private, max-age=0, no-transform" \
187 "gs://$gs_path"/**.html > /dev/null 2>&1
189 echo "Document link(s):" >> gerrit_comment.txt
190 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
191 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
194 name: report-docs-build-result-to-gerrit
201 export PATH=$PATH:/usr/local/bin/
202 if [[ -e gerrit_comment.txt ]] ; then
204 echo "posting review comment to gerrit..."
206 cat gerrit_comment.txt
208 ssh -p 29418 gerrit.opnfv.org \
209 "gerrit review -p $GERRIT_PROJECT \
210 -m '$(cat gerrit_comment.txt)' \
211 $GERRIT_PATCHSET_REVISION \
216 name: remove-old-docs-from-opnfv-artifacts
223 export PATH=$PATH:/usr/local/bin/
225 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
227 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
229 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
231 echo "Deleting Out-of-dated Documents..."
232 gsutil -m rm -r "gs://$gs_path"
234 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
236 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
238 echo "Deleting Out-of-dated Documents..."
239 gsutil -m rm -r "gs://$gs_path"
243 name: build-and-upload-artifacts-json-api
249 export PATH=$PATH:/usr/local/bin/
251 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
252 source $WORKSPACE/releng_artifacts/bin/activate
254 # install python packages
255 pip install google-api-python-client
257 # generate and upload index file
258 echo "Generating Artifacts API ..."
259 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
260 gsutil cp index.json gs://artifacts.opnfv.org/index.json
265 name: lint-python-code
272 export PATH=$PATH:/usr/local/bin/
274 virtualenv -p python2.7 $WORKSPACE/releng_flake8
275 source $WORKSPACE/releng_flake8/bin/activate
277 # install python packages
278 pip install "flake8==2.6.2"
280 # generate and upload lint log
281 echo "Running flake8 code on $PROJECT ..."
283 # Get number of flake8 violations. If none, this will be an
285 FLAKE_COUNT="$(find . \
286 -path './releng_flake8' -prune -o \
287 -path './.tox' -prune -o \
288 -type f -name "*.py" -print | \
289 xargs flake8 --exit-zero -qq --count 2>&1)"
291 # Ensure we start with a clean environment
294 if [ ! -z $FLAKE_COUNT ]; then
295 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
297 -path './releng_flake8' -prune -o \
298 -path './.tox' -prune -o \
299 -type f -name "*.py" -print | \
300 xargs flake8 --exit-zero --first >> violation.log
301 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
302 echo -e "First $SHOWN shown\n---" >> lint.log
303 cat violation.log >> lint.log
304 sed -r -i '4,$s/^/ /g' lint.log
311 name: report-lint-result-to-gerrit
318 export PATH=$PATH:/usr/local/bin/
320 # If no violations were found, no lint log will exist.
321 if [[ -e lint.log ]] ; then
322 echo -e "\nposting linting report to gerrit...\n"
327 ssh -p 29418 gerrit.opnfv.org \
328 "gerrit review -p $GERRIT_PROJECT \
329 -m \"$(cat lint.log)\" \
330 $GERRIT_PATCHSET_REVISION \
337 name: upload-review-docs
339 - build-html-and-pdf-docs-output
340 - upload-under-review-docs-to-opnfv-artifacts
341 - report-docs-build-result-to-gerrit
344 name: upload-merged-docs
346 - build-html-and-pdf-docs-output
347 - upload-generated-docs-to-opnfv-artifacts
348 - report-docs-build-result-to-gerrit
349 - remove-old-docs-from-opnfv-artifacts
352 name: check-bash-syntax
354 - shell: "find . -name '*.sh' | xargs bash -n"
364 export PATH=$PATH:/usr/local/bin/
366 # install python packages
367 pip install "yamllint==1.6.0"
369 # generate and upload lint log
370 echo "Running yaml code on $PROJECT ..."
372 # Ensure we start with a clean environment
373 rm -f yaml-violation.log lint.log
375 # Get number of yaml violations. If none, this will be an
378 -type f -name "*.yml" -print \
379 -o -name "*.yaml" -print | \
380 xargs yamllint > yaml-violation.log || true
382 if [ -s "yaml-violation.log" ]; then
383 SHOWN=$(cat yaml-violation.log| grep -v "^$" |wc -l)
384 echo -e "First $SHOWN shown\n---" > lint.log
385 cat yaml-violation.log >> lint.log
386 sed -r -i '4,$s/^/ /g' lint.log
390 name: archive-artifacts
393 artifacts: '{artifacts}'