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 echo "gs_path="$GS_URL/docs""
175 echo "local_path="upload/docs""
177 gs_path="$GS_URL/docs"
178 local_path="upload/docs"
181 mv docs_output "$local_path"
184 echo "gsutil -m cp -r "$local_path"/* "gs://$gs_path""
185 gsutil -m cp -r "$local_path"/* "gs://$gs_path"
188 -h "Content-Type:text/html" \
189 -h "Cache-Control:private, max-age=0, no-transform" \
190 "gs://$gs_path"/**.html > /dev/null 2>&1
192 echo "Document link(s):" >> gerrit_comment.txt
193 find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
194 sed -e "s|^$local_path| http://$gs_path|" >> gerrit_comment.txt
197 name: report-docs-build-result-to-gerrit
204 export PATH=$PATH:/usr/local/bin/
205 if [[ -e gerrit_comment.txt ]] ; then
207 echo "posting review comment to gerrit..."
209 cat gerrit_comment.txt
211 ssh -p 29418 gerrit.opnfv.org \
212 "gerrit review -p $GERRIT_PROJECT \
213 -m '$(cat gerrit_comment.txt)' \
214 $GERRIT_PATCHSET_REVISION \
219 name: remove-old-docs-from-opnfv-artifacts
226 export PATH=$PATH:/usr/local/bin/
228 [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
230 gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
232 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
234 echo "Deleting Out-of-dated Documents..."
235 gsutil -m rm -r "gs://$gs_path"
237 gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
239 if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
241 echo "Deleting Out-of-dated Documents..."
242 gsutil -m rm -r "gs://$gs_path"
246 name: build-and-upload-artifacts-json-api
252 export PATH=$PATH:/usr/local/bin/
254 virtualenv -p python2.7 $WORKSPACE/releng_artifacts
255 source $WORKSPACE/releng_artifacts/bin/activate
257 # install python packages
258 pip install google-api-python-client
260 # generate and upload index file
261 echo "Generating Artifacts API ..."
262 python $WORKSPACE/utils/opnfv-artifacts.py > index.json
263 gsutil cp index.json gs://artifacts.opnfv.org/index.json
268 name: lint-python-code
275 export PATH=$PATH:/usr/local/bin/
277 virtualenv -p python2.7 $WORKSPACE/releng_flake8
278 source $WORKSPACE/releng_flake8/bin/activate
280 # install python packages
281 pip install "flake8==2.6.2"
283 # generate and upload lint log
284 echo "Running flake8 code on $PROJECT ..."
286 # Get number of flake8 violations. If none, this will be an
288 FLAKE_COUNT="$(find . \
289 -path './releng_flake8' -prune -o \
290 -path './.tox' -prune -o \
291 -type f -name "*.py" -print | \
292 xargs flake8 --exit-zero -qq --count 2>&1)"
294 # Ensure we start with a clean environment
297 if [ ! -z $FLAKE_COUNT ]; then
298 echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
300 -path './releng_flake8' -prune -o \
301 -path './.tox' -prune -o \
302 -type f -name "*.py" -print | \
303 xargs flake8 --exit-zero --first >> violation.log
304 SHOWN=$(wc -l violation.log | cut -d' ' -f1)
305 echo -e "First $SHOWN shown\n---" >> lint.log
306 cat violation.log >> lint.log
307 sed -r -i '4,$s/^/ /g' lint.log
314 name: report-lint-result-to-gerrit
321 export PATH=$PATH:/usr/local/bin/
323 # If no violations were found, no lint log will exist.
324 if [[ -e lint.log ]] ; then
325 echo -e "\nposting linting report to gerrit...\n"
330 ssh -p 29418 gerrit.opnfv.org \
331 "gerrit review -p $GERRIT_PROJECT \
332 -m \"$(cat lint.log)\" \
333 $GERRIT_PATCHSET_REVISION \
340 name: upload-review-docs
342 - build-html-and-pdf-docs-output
343 - upload-under-review-docs-to-opnfv-artifacts
344 - report-docs-build-result-to-gerrit
347 name: upload-merged-docs
349 - build-html-and-pdf-docs-output
350 - upload-generated-docs-to-opnfv-artifacts
351 - report-docs-build-result-to-gerrit
352 - remove-old-docs-from-opnfv-artifacts
355 name: check-bash-syntax
357 - shell: "find . -name '*.sh' | xargs bash -n"