Merge "doctor: make test script run in doctor-verify job"
[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 -e
163             export PATH=$PATH:/usr/local/bin/
164             git clone ssh://gerrit.opnfv.org:29418/releng
165             GERRIT_COMMENT=gerrit_comment.txt ./releng/utils/docs-build.sh
166
167 - builder:
168     name: upload-under-review-docs-to-opnfv-artifacts
169     builders:
170         - shell: |
171             #!/bin/bash -e
172             set -o pipefail
173             export PATH=$PATH:/usr/local/bin/
174
175             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
176             [[ -d docs_output ]] || exit 0
177
178             echo
179             echo "###########################"
180             echo "UPLOADING DOCS UNDER REVIEW"
181             echo "###########################"
182             echo
183
184             gs_base="artifacts.opnfv.org/review"
185             gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
186             local_path="upload/$GERRIT_CHANGE_NUMBER"
187
188             mkdir -p upload
189             mv docs_output "$local_path"
190             gsutil -m cp -r "$local_path" "gs://$gs_base"
191
192             if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
193                 gsutil -m setmeta \
194                     -h "Content-Type:text/html" \
195                     -h "Cache-Control:private, max-age=0, no-transform" \
196                     "gs://$gs_path"/**.html
197             fi
198
199             echo "Document link(s):" >> gerrit_comment.txt
200             find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
201                 sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
202
203 - builder:
204     name: upload-generated-docs-to-opnfv-artifacts
205     builders:
206         - shell: |
207             #!/bin/bash -e
208             set -o pipefail
209             export PATH=$PATH:/usr/local/bin/
210
211             [[ -d docs_output ]] || exit 0
212
213             echo
214             echo "########################"
215             echo "UPLOADING GENERATED DOCS"
216             echo "########################"
217             echo
218
219             gs_path="$GS_URL/docs"
220             local_path="upload/docs"
221
222             mkdir -p upload
223             mv docs_output "$local_path"
224             gsutil -m cp -r "$local_path" "gs://$GS_URL"
225
226             if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
227                 gsutil -m setmeta \
228                     -h "Content-Type:text/html" \
229                     -h "Cache-Control:private, max-age=0, no-transform" \
230                     "gs://$gs_path"/**.html
231             fi
232
233             echo "Document link(s):" >> gerrit_comment.txt
234             find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
235                 sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
236
237 - builder:
238     name: report-docs-build-result-to-gerrit
239     builders:
240         - shell: |
241             #!/bin/bash -e
242             export PATH=$PATH:/usr/local/bin/
243             if [[ -e gerrit_comment.txt ]] ; then
244                 echo
245                 echo "posting review comment to gerrit..."
246                 echo
247                 cat gerrit_comment.txt
248                 echo
249                 ssh -p 29418 gerrit.opnfv.org \
250                     "gerrit review -p $GERRIT_PROJECT \
251                      -m '$(cat gerrit_comment.txt)' \
252                      $GERRIT_PATCHSET_REVISION"
253             fi
254
255 - builder:
256     name: remove-old-docs-from-opnfv-artifacts
257     builders:
258         - shell: |
259             #!/bin/bash -e
260             export PATH=$PATH:/usr/local/bin/
261
262             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
263
264             gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
265
266             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
267                 echo
268                 echo "Deleting Out-of-dated Documents..."
269                 gsutil -m rm -r "gs://$gs_path"
270             fi
271
272 - builder:
273     name: upload-review-docs
274     builders:
275         - build-html-and-pdf-docs-output
276         - upload-under-review-docs-to-opnfv-artifacts
277         - report-docs-build-result-to-gerrit
278
279 - builder:
280     name: upload-merged-docs
281     builders:
282         - build-html-and-pdf-docs-output
283         - upload-generated-docs-to-opnfv-artifacts
284         - report-docs-build-result-to-gerrit
285         - remove-old-docs-from-opnfv-artifacts