4 name: project-parameter
9 description: "JJB configured PROJECT parameter to identify an opnfv Gerrit project"
12 default: artifacts.opnfv.org/$PROJECT
13 description: "URL to Google Storage."
16 default: build.opnfv.org/artifacts.opnfv.org/$PROJECT
17 description: "URL to Google Storage proxy"
20 name: gerrit-parameter
25 description: "JJB configured GERRIT_BRANCH parameter"
31 credentials-id: '{credentials-id}'
40 name: gerrit-trigger-scm
43 credentials-id: '{credentials-id}'
47 - 'origin/$GERRIT_BRANCH'
49 choosing-strategy: '{choosing-strategy}'
53 name: 'daily-trigger-disabled'
58 name: 'weekly-trigger-disabled'
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}'
83 name: gerrit-trigger-patch-merged
86 server-name: 'gerrit.opnfv.org'
89 - comment-added-contains-event:
90 comment-contains-value: 'remerge'
92 - project-compare-type: 'ANT'
93 project-pattern: '{name}'
95 - branch-compare-type: 'ANT'
96 branch-pattern: '**/{branch}'
99 name: archive-artifacts
102 artifacts: '{artifacts}'
110 name: build-html-and-pdf-docs-output
116 export PATH=$PATH:/usr/local/bin/
117 git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
118 GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
121 name: upload-under-review-docs-to-opnfv-artifacts
128 export PATH=$PATH:/usr/local/bin/
130 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
131 [[ -d docs_output ]] || exit 0
134 echo "###########################"
135 echo "UPLOADING DOCS UNDER REVIEW"
136 echo "###########################"
139 gs_base="artifacts.opnfv.org/$PROJECT/review"
140 gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
141 local_path="upload/$GERRIT_CHANGE_NUMBER"
144 mv docs_output "$local_path"
145 gsutil -m cp -r "$local_path" "gs://$gs_base"
148 -h "Content-Type:text/html" \
149 -h "Cache-Control:private, max-age=0, no-transform" \
150 "gs://$gs_path"/**.html > /dev/null 2>&1
152 echo "Document link(s):" >> gerrit_comment.txt
153 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
154 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
157 name: upload-generated-docs-to-opnfv-artifacts
164 export PATH=$PATH:/usr/local/bin/
166 [[ -d docs_output ]] || exit 0
169 echo "########################"
170 echo "UPLOADING GENERATED DOCS"
171 echo "########################"
174 gs_path="$GS_URL/docs"
175 local_path="upload/docs"
178 mv docs_output "$local_path"
179 gsutil -m cp -r "$local_path" "gs://$GS_URL"
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: report-docs-build-result-to-gerrit
198 export PATH=$PATH:/usr/local/bin/
199 if [[ -e gerrit_comment.txt ]] ; then
201 echo "posting review comment to gerrit..."
203 cat gerrit_comment.txt
205 ssh -p 29418 gerrit.opnfv.org \
206 "gerrit review -p $GERRIT_PROJECT \
207 -m '$(cat gerrit_comment.txt)' \
208 $GERRIT_PATCHSET_REVISION \
213 name: remove-old-docs-from-opnfv-artifacts
220 export PATH=$PATH:/usr/local/bin/
222 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
224 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
226 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
228 echo "Deleting Out-of-dated Documents..."
229 gsutil -m rm -r "gs://$gs_path"
231 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
233 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
235 echo "Deleting Out-of-dated Documents..."
236 gsutil -m rm -r "gs://$gs_path"
240 name: build-and-upload-artifacts-json-api
246 export PATH=$PATH:/usr/local/bin/
248 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
249 source $WORKSPACE/releng_artifacts/bin/activate
251 # install python packages
252 pip install google-api-python-client
254 # generate and upload index file
255 echo "Generating Artifacts API ..."
256 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
257 gsutil cp index.json gs://artifacts.opnfv.org/index.json
262 name: lint-python-code
269 export PATH=$PATH:/usr/local/bin/
271 virtualenv -p python2.7 $WORKSPACE/releng_flake8
272 source $WORKSPACE/releng_flake8/bin/activate
274 # install python packages
275 pip install "flake8==2.6.2"
277 # generate and upload lint log
278 echo "Running flake8 code on $PROJECT ..."
280 # Get number of flake8 violations. If none, this will be an
282 FLAKE_COUNT="$(find . \
283 -path './releng_flake8' -prune -o \
284 -path './.tox' -prune -o \
285 -type f -name "*.py" -print | \
286 xargs flake8 --exit-zero -qq --count 2>&1)"
288 # Ensure we start with a clean environment
291 if [ ! -z $FLAKE_COUNT ]; then
292 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
294 -path './releng_flake8' -prune -o \
295 -path './.tox' -prune -o \
296 -type f -name "*.py" -print | \
297 xargs flake8 --exit-zero --first >> violation.log
298 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
299 echo -e "First $SHOWN shown\n---" >> lint.log
300 cat violation.log >> lint.log
301 sed -r -i '4,$s/^/ /g' lint.log
308 name: report-lint-result-to-gerrit
315 export PATH=$PATH:/usr/local/bin/
317 # If no violations were found, no lint log will exist.
318 if [[ -e lint.log ]] ; then
319 echo -e "\nposting linting report to gerrit...\n"
324 ssh -p 29418 gerrit.opnfv.org \
325 "gerrit review -p $GERRIT_PROJECT \
326 -m \"$(cat lint.log)\" \
327 $GERRIT_PATCHSET_REVISION \
334 name: upload-review-docs
336 - build-html-and-pdf-docs-output
337 - upload-under-review-docs-to-opnfv-artifacts
338 - report-docs-build-result-to-gerrit
341 name: upload-merged-docs
343 - build-html-and-pdf-docs-output
344 - upload-generated-docs-to-opnfv-artifacts
345 - report-docs-build-result-to-gerrit
346 - remove-old-docs-from-opnfv-artifacts
349 name: check-bash-syntax
351 - shell: "find . -name '*.sh' | xargs bash -n"