jjb: fix default file path of conf.py
[releng.git] / jjb / releng-macros.yaml
1 # OLD Releng macros
2
3 - parameter:
4     name: project-parameter
5     parameters:
6         - string:
7             name: PROJECT
8             default: '{project}'
9             description: "JJB configured PROJECT parameter to identify an opnfv Gerrit project"
10
11 - parameter:
12     name: gerrit-parameter
13     parameters:
14         - string:
15             name: GERRIT_BRANCH
16             default: '{branch}'
17             description: "JJB configured GERRIT_BRANCH parameter"
18
19 - scm:
20     name: git-scm
21     scm:
22         - git:
23             credentials-id: '{credentials-id}'
24             url: '$GIT_BASE'
25             refspec: ''
26             branches:
27                 - 'origin/{branch}'
28             skip-tag: true
29             wipe-workspace: true
30
31 - scm:
32     name: gerrit-trigger-scm
33     scm:
34         - git:
35             credentials-id: '{credentials-id}'
36             url: '$GIT_BASE'
37             refspec: '{refspec}'
38             branches:
39                 - 'origin/$GERRIT_BRANCH'
40             skip-tag: true
41             choosing-strategy: '{choosing-strategy}'
42
43 - wrapper:
44     name: build-timeout
45     wrappers:
46         - timeout:
47             type: absolute
48             timeout: 360
49             fail: true
50
51 - trigger:
52     name: gerrit-trigger-patch-submitted
53     triggers:
54         - gerrit:
55             server-name: 'gerrit.opnfv.org'
56             trigger-on:
57                 - patchset-created-event:
58                     exclude-drafts: 'false'
59                     exclude-trivial-rebase: 'false'
60                     exclude-no-code-change: 'false'
61                 - draft-published-event
62                 - comment-added-contains-event:
63                     comment-contains-value: 'recheck'
64             projects:
65               - project-compare-type: 'ANT'
66                 project-pattern: '{name}'
67                 branches:
68                   - branch-compare-type: 'ANT'
69                     branch-pattern: '**/{branch}'
70
71 - trigger:
72     name: gerrit-trigger-patch-merged
73     triggers:
74         - gerrit:
75             server-name: 'gerrit.opnfv.org'
76             trigger-on:
77                 - change-merged-event
78                 - comment-added-contains-event:
79                     comment-contains-value: 'remerge'
80             projects:
81               - project-compare-type: 'ANT'
82                 project-pattern: '{name}'
83                 branches:
84                   - branch-compare-type: 'ANT'
85                     branch-pattern: '**/{branch}'
86
87 - publisher:
88     name: archive-artifacts
89     publishers:
90         - archive:
91             artifacts: '{artifacts}'
92             allow-empty: true
93             fingerprint: true
94             latest-only: true
95
96 - publisher:
97     name: email-notification
98     publishers:
99         - email-ext:
100             recipients: 'jenkins@lists.opnfv.org'
101             reply-to:
102             content-type: default
103             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
104             body: |
105                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
106
107                 Check console output at $BUILD_URL to view the results.
108             unstable: true
109             fixed: true
110             send-to:
111                 - developers
112                 - recipients
113
114 - publisher:
115         name: jacoco-report
116         publishers:
117             - jacoco:
118                 exec-pattern: "**/**.exec"
119                 class-pattern: "**/classes"
120                 source-pattern: "**/src/main/java"
121                 exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**"
122                 status-update: true
123                 targets:
124                   - branch:
125                       healthy: 10
126                       unhealthy: 20
127                   - method:
128                       healthy: 50
129                       unhealthy: 40
130
131
132 - builder:
133     name: test-macro
134     builders:
135         - shell: 'echo testing macro "test-macro"'
136
137 - builder:
138     name: wipe-org-opendaylight-repo
139     builders:
140         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
141
142 - builder:
143     name: jacoco-nojava-workaround
144     builders:
145         - shell: 'mkdir -p $WORKSPACE/target/classes'
146
147
148 # New Releng macros
149
150 - builder:
151     name: build-html-and-pdf-docs-output
152     builders:
153         - shell: |
154             #!/bin/bash -e
155             set -o pipefail
156             export PATH=$PATH:/usr/local/bin/
157
158             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
159
160             _get_title_script="
161             import os
162             from docutils import core
163             with open('index.rst', 'r') as file:
164                 data = file.read()
165                 doctree = core.publish_doctree(data,
166                     settings_overrides={'report_level': 5,
167                                         'halt_level': 5})
168                 print doctree[0].astext()"
169             _git_sha1="$(git rev-parse HEAD)"
170
171             find docs/ -name 'index.rst' -printf '%h\n' | while read dir
172             do
173                 _name="${dir##*/}"
174                 _build="$dir/build"
175                 _output="docs/output/$_name"
176
177                 echo
178                 echo "#################${dir//?/#}"
179                 echo "Building DOCS in $dir"
180                 echo "#################${dir//?/#}"
181                 echo
182
183                 sed -i "s/_sha1_/$_git_sha1/g" "$dir/index.rst"
184
185                 if [[ ! -f "$dir/conf.py" ]] ; then
186                     cp "docs/etc/conf.py" "$dir/conf.py"
187                     _title=$(cd $dir; python -c "$_get_title_script")
188                     echo "latex_documents = [('index', '$_name.tex', '$_title', 'OPNFV', 'manual'),]" >> "$dir/conf.py"
189                 fi
190
191                 mkdir -p "$_output"
192
193                 sphinx-build -b html -E "$dir" "$_output"
194
195                 # Note: PDF creation may fail in project doc builds.
196                 #       We allow this test to be marked as succeeded with
197                 #       failure in PDF creation, but leave message to fix it.
198                 #       Any failure has to be fixed before B release.
199                 {
200                     sphinx-build -b latex -E "$dir" "$_build"
201                     make -C "$_build" LATEXOPTS='--interaction=nonstopmode' all-pdf
202                     mv "$_build"/*.pdf "$_output"
203                 } || {
204                     _msg="Error: PDF creation for $dir has failed, please fix source rst file(s)."
205                     echo
206                     echo "$_msg"
207                     echo
208                     echo "$_msg" >> gerrit_comment.txt
209                 }
210             done
211
212 - builder:
213     name: upload-under-review-docs-to-opnfv-artifacts
214     builders:
215         - shell: |
216             #!/bin/bash -e
217             set -o pipefail
218             export PATH=$PATH:/usr/local/bin/
219
220             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
221             [[ -d docs/output ]]
222
223             echo
224             echo "###########################"
225             echo "UPLOADING DOCS UNDER REVIEW"
226             echo "###########################"
227             echo
228
229             gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
230
231             gsutil -m cp -r docs/output/* "gs://$gs_path"
232
233             if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
234                 gsutil -m setmeta \
235                     -h "Content-Type:text/html" \
236                     -h "Cache-Control:private, max-age=0, no-transform" \
237                     "gs://$gs_path"/**.html
238             fi
239
240             echo "Document link(s):" >> gerrit_comment.txt
241             find docs/output | grep -e 'index.html$' -e 'pdf$' | \
242                 sed -e "s|^docs/output|    http://$gs_path|" >> gerrit_comment.txt
243
244 - builder:
245     name: upload-merged-docs-to-opnfv-artifacts
246     builders:
247         - shell: |
248             #!/bin/bash -e
249             set -o pipefail
250             export PATH=$PATH:/usr/local/bin/
251
252             [[ -d docs/output ]]
253
254             echo
255             echo "#####################"
256             echo "UPLOADING MERGED DOCS"
257             echo "#####################"
258             echo
259
260             if [[ "$GERRIT_BRANCH" == "master" ]] ; then
261                 gs_path="artifacts.opnfv.org/$GERRIT_PROJECT/docs"
262             else
263                 gs_path="artifacts.opnfv.org/$GERRIT_PROJECT/$GERRIT_BRANCH/docs"
264             fi
265
266             gsutil -m cp -r docs/output/* "gs://$gs_path"
267
268             if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
269                 gsutil -m setmeta \
270                     -h "Content-Type:text/html" \
271                     -h "Cache-Control:private, max-age=0, no-transform" \
272                     "gs://$gs_path"/**.html
273             fi
274
275             echo "Document link(s):" >> gerrit_comment.txt
276             find docs/output | grep -e 'index.html$' -e 'pdf$' | \
277                 sed -e "s|^docs/output|    http://$gs_path|" >> gerrit_comment.txt
278
279 - builder:
280     name: report-docs-build-result-to-gerrit
281     builders:
282         - shell: |
283             #!/bin/bash -e
284             export PATH=$PATH:/usr/local/bin/
285             if [[ -e gerrit_comment.txt ]] ; then
286                 echo
287                 echo "posting review comment to gerrit..."
288                 echo
289                 cat gerrit_comment.txt
290                 echo
291                 ssh -p 29418 gerrit.opnfv.org \
292                     "gerrit review -p $GERRIT_PROJECT \
293                      -m '$(cat gerrit_comment.txt)' \
294                      $GERRIT_PATCHSET_REVISION"
295             fi
296
297 - builder:
298     name: remove-old-docs-from-opnfv-artifacts
299     builders:
300         - shell: |
301             #!/bin/bash -e
302             export PATH=$PATH:/usr/local/bin/
303
304             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
305
306             gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
307
308             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
309                 echo
310                 echo "Deleting Out-of-dated Documents..."
311                 gsutil -m rm -r "gs://$gs_path"
312             fi
313
314 - builder:
315     name: upload-review-docs
316     builders:
317         - build-html-and-pdf-docs-output
318         - upload-under-review-docs-to-opnfv-artifacts
319         - report-docs-build-result-to-gerrit
320
321 - builder:
322     name: upload-merged-docs
323     builders:
324         - build-html-and-pdf-docs-output
325         - upload-merged-docs-to-opnfv-artifacts
326         - report-docs-build-result-to-gerrit
327         - remove-old-docs-from-opnfv-artifacts