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