b43a76d5f50d7d95c4c554ee93f03ca11ef74abd
[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         - string:
11             name: GS_BASE
12             default: artifacts.opnfv.org/$PROJECT
13             description: "URL to Google Storage."
14         - string:
15             name: GS_BASE_PROXY
16             default: build.opnfv.org/artifacts/$PROJECT
17             description: "URL to Google Storage proxy"
18
19 - parameter:
20     name: gerrit-parameter
21     parameters:
22         - string:
23             name: GERRIT_BRANCH
24             default: '{branch}'
25             description: "JJB configured GERRIT_BRANCH parameter"
26
27 - scm:
28     name: git-scm
29     scm:
30         - git:
31             credentials-id: '{credentials-id}'
32             url: '$GIT_BASE'
33             refspec: ''
34             branches:
35                 - 'origin/{branch}'
36             skip-tag: true
37             wipe-workspace: true
38
39 - scm:
40     name: gerrit-trigger-scm
41     scm:
42         - git:
43             credentials-id: '{credentials-id}'
44             url: '$GIT_BASE'
45             refspec: '{refspec}'
46             branches:
47                 - 'origin/$GERRIT_BRANCH'
48             skip-tag: true
49             choosing-strategy: '{choosing-strategy}'
50
51 - wrapper:
52     name: build-timeout
53     wrappers:
54         - timeout:
55             type: absolute
56             timeout: 360
57             fail: true
58
59 - trigger:
60     name: 'brahmaputra-trigger-daily-disabled'
61     triggers:
62         - timed: ''
63
64 - trigger:
65     name: 'brahmaputra-trigger-daily-enabled'
66     triggers:
67         - timed: '0 2 * * *'
68
69 - trigger:
70     name: gerrit-trigger-patch-submitted
71     triggers:
72         - gerrit:
73             server-name: 'gerrit.opnfv.org'
74             trigger-on:
75                 - patchset-created-event:
76                     exclude-drafts: 'false'
77                     exclude-trivial-rebase: 'false'
78                     exclude-no-code-change: 'false'
79                 - draft-published-event
80                 - comment-added-contains-event:
81                     comment-contains-value: 'recheck'
82             projects:
83               - project-compare-type: 'ANT'
84                 project-pattern: '{name}'
85                 branches:
86                   - branch-compare-type: 'ANT'
87                     branch-pattern: '**/{branch}'
88
89 - trigger:
90     name: gerrit-trigger-patch-merged
91     triggers:
92         - gerrit:
93             server-name: 'gerrit.opnfv.org'
94             trigger-on:
95                 - change-merged-event
96                 - comment-added-contains-event:
97                     comment-contains-value: 'remerge'
98             projects:
99               - project-compare-type: 'ANT'
100                 project-pattern: '{name}'
101                 branches:
102                   - branch-compare-type: 'ANT'
103                     branch-pattern: '**/{branch}'
104
105 - publisher:
106     name: archive-artifacts
107     publishers:
108         - archive:
109             artifacts: '{artifacts}'
110             allow-empty: true
111             fingerprint: true
112             latest-only: true
113
114 - publisher:
115     name: email-notification
116     publishers:
117         - email-ext:
118             recipients: 'jenkins@lists.opnfv.org'
119             reply-to:
120             content-type: default
121             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
122             body: |
123                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
124
125                 Check console output at $BUILD_URL to view the results.
126             unstable: true
127             fixed: true
128             send-to:
129                 - developers
130                 - recipients
131
132 - publisher:
133         name: jacoco-report
134         publishers:
135             - jacoco:
136                 exec-pattern: "**/**.exec"
137                 class-pattern: "**/classes"
138                 source-pattern: "**/src/main/java"
139                 exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**"
140                 status-update: true
141                 targets:
142                   - branch:
143                       healthy: 10
144                       unhealthy: 20
145                   - method:
146                       healthy: 50
147                       unhealthy: 40
148
149
150 - builder:
151     name: test-macro
152     builders:
153         - shell: 'echo testing macro "test-macro"'
154
155 - builder:
156     name: wipe-org-opendaylight-repo
157     builders:
158         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
159
160 - builder:
161     name: jacoco-nojava-workaround
162     builders:
163         - shell: 'mkdir -p $WORKSPACE/target/classes'
164
165
166 # New Releng macros
167
168 - builder:
169     name: build-html-and-pdf-docs-output
170     builders:
171         - shell: |
172             #!/bin/bash
173             set -o errexit
174             set -o xtrace
175             export PATH=$PATH:/usr/local/bin/
176             git clone ssh://gerrit.opnfv.org:29418/releng
177             GERRIT_COMMENT=gerrit_comment.txt ./releng/utils/docs-build.sh
178
179 - builder:
180     name: upload-under-review-docs-to-opnfv-artifacts
181     builders:
182         - shell: |
183             #!/bin/bash
184             set -o errexit
185             set -o pipefail
186             set -o xtrace
187             export PATH=$PATH:/usr/local/bin/
188
189             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
190             [[ -d docs_output ]] || exit 0
191
192             echo
193             echo "###########################"
194             echo "UPLOADING DOCS UNDER REVIEW"
195             echo "###########################"
196             echo
197
198             gs_base="artifacts.opnfv.org/$PROJECT/review"
199             gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
200             local_path="upload/$GERRIT_CHANGE_NUMBER"
201
202             mkdir -p upload
203             mv docs_output "$local_path"
204             gsutil -m cp -r "$local_path" "gs://$gs_base"
205
206             if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
207                 gsutil -m setmeta \
208                     -h "Content-Type:text/html" \
209                     -h "Cache-Control:private, max-age=0, no-transform" \
210                     "gs://$gs_path"/**.html
211             fi
212
213             echo "Document link(s):" >> gerrit_comment.txt
214             find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
215                 sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
216
217 - builder:
218     name: upload-generated-docs-to-opnfv-artifacts
219     builders:
220         - shell: |
221             #!/bin/bash
222             set -o errexit
223             set -o pipefail
224             set -o xtrace
225             export PATH=$PATH:/usr/local/bin/
226
227             [[ -d docs_output ]] || exit 0
228
229             echo
230             echo "########################"
231             echo "UPLOADING GENERATED DOCS"
232             echo "########################"
233             echo
234
235             gs_path="$GS_URL/docs"
236             local_path="upload/docs"
237
238             mkdir -p upload
239             mv docs_output "$local_path"
240             gsutil -m cp -r "$local_path" "gs://$GS_URL"
241
242             if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
243                 gsutil -m setmeta \
244                     -h "Content-Type:text/html" \
245                     -h "Cache-Control:private, max-age=0, no-transform" \
246                     "gs://$gs_path"/**.html
247             fi
248
249             echo "Document link(s):" >> gerrit_comment.txt
250             find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
251                 sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
252
253 - builder:
254     name: report-docs-build-result-to-gerrit
255     builders:
256         - shell: |
257             #!/bin/bash
258             set -o errexit
259             set -o pipefail
260             set -o xtrace
261             export PATH=$PATH:/usr/local/bin/
262             if [[ -e gerrit_comment.txt ]] ; then
263                 echo
264                 echo "posting review comment to gerrit..."
265                 echo
266                 cat gerrit_comment.txt
267                 echo
268                 ssh -p 29418 gerrit.opnfv.org \
269                     "gerrit review -p $GERRIT_PROJECT \
270                      -m '$(cat gerrit_comment.txt)' \
271                      $GERRIT_PATCHSET_REVISION"
272             fi
273
274 - builder:
275     name: remove-old-docs-from-opnfv-artifacts
276     builders:
277         - shell: |
278             #!/bin/bash
279             set -o errexit
280             set -o pipefail
281             set -o xtrace
282             export PATH=$PATH:/usr/local/bin/
283
284             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
285
286             gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
287
288             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
289                 echo
290                 echo "Deleting Out-of-dated Documents..."
291                 gsutil -m rm -r "gs://$gs_path"
292             fi
293             gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
294
295             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
296                 echo
297                 echo "Deleting Out-of-dated Documents..."
298                 gsutil -m rm -r "gs://$gs_path"
299             fi
300
301 - builder:
302     name: upload-review-docs
303     builders:
304         - build-html-and-pdf-docs-output
305         - upload-under-review-docs-to-opnfv-artifacts
306         - report-docs-build-result-to-gerrit
307
308 - builder:
309     name: upload-merged-docs
310     builders:
311         - build-html-and-pdf-docs-output
312         - upload-generated-docs-to-opnfv-artifacts
313         - report-docs-build-result-to-gerrit
314         - remove-old-docs-from-opnfv-artifacts