3be93c8895d03567025271de7ae9cec3ec651624
[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             git_sha1="$(git rev-parse HEAD)"
161
162             find docs/ -type f -iname '*.rst' -print0 | while read file
163             do
164                 sed -i "s/_sha1_/$git_sha1/g" "$file"
165             done
166
167             find docs/ -name 'index.rst' -printf '%h\n' | while read dir
168             do
169                 _name="${dir##*/}"
170                 _build="$dir/build"
171                 _output="docs/output/$_name"
172
173                 echo
174                 echo "#################${dir//?/#}"
175                 echo "Building DOCS in $dir"
176                 echo "#################${dir//?/#}"
177                 echo
178
179                 mkdir -p "$_output"
180
181                 sphinx-build -b html -E -c docs/etc "$dir" "$_output"
182
183                 #sphinx-build -b latex -E -c docs/etc -D project=$_name "$dir" "$_build"
184                 #make -C "$_build" LATEXOPTS='--interaction=nonstopmode' all-pdf
185                 #mv "$_build"/*.pdf "$_output"
186             done
187
188 #TODO(r-mibu): change this to publisher
189 - builder:
190     name: upload-under-review-docs-to-opnfv-artifacts
191     builders:
192         - shell: |
193             #!/bin/bash -e
194             set -o pipefail
195             export PATH=$PATH:/usr/local/bin/
196
197             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
198             [[ -d docs/output ]]
199
200             echo
201             echo "###########################"
202             echo "UPLOADING DOCS UNDER REVIEW"
203             echo "###########################"
204             echo
205
206             gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
207
208             gsutil -m cp -r docs/output/* "gs://$gs_path"
209
210             if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
211                 gsutil -m setmeta \
212                     -h "Content-Type:text/html" \
213                     -h "Cache-Control:private, max-age=0, no-transform" \
214                     "gs://$gs_path"/**.html
215             fi
216
217             files=$(find docs/output | grep -e 'index.html$' -e 'pdf$' | \
218                     sed -e "s|^docs/output|    http://$gs_path|")
219             gerrit_comment="Document link(s):
220             $files"
221             echo
222             echo "$gerrit_comment"
223             echo
224             ssh -p 29418 gerrit.opnfv.org "gerrit review -p $GERRIT_PROJECT -m '$gerrit_comment' $GERRIT_PATCHSET_REVISION"
225
226 #TODO(r-mibu): change this to publisher
227 - builder:
228     name: upload-merged-docs-to-opnfv-artifacts
229     builders:
230         - shell: |
231             #!/bin/bash -e
232             set -o pipefail
233             export PATH=$PATH:/usr/local/bin/
234
235             [[ -d docs/output ]]
236
237             echo
238             echo "#####################"
239             echo "UPLOADING MERGED DOCS"
240             echo "#####################"
241             echo
242
243             if [[ "$GERRIT_BRANCH" == "master" ]] ; then
244                 gs_path="artifacts.opnfv.org/$GERRIT_PROJECT/docs"
245             else
246                 gs_path="artifacts.opnfv.org/$GERRIT_PROJECT/$GERRIT_BRANCH/docs"
247             fi
248
249             gsutil -m cp -r docs/output/* "gs://$gs_path"
250
251             if gsutil ls "gs://$gs_path" | grep -e 'html$' > /dev/null 2>&1 ; then
252                 gsutil -m setmeta \
253                     -h "Content-Type:text/html" \
254                     -h "Cache-Control:private, max-age=0, no-transform" \
255                     "gs://$gs_path"/**.html
256             fi
257
258             files=$(find docs/output | grep -e 'index.html$' -e 'pdf$' | \
259                     sed -e "s|^docs/output|    http://$gs_path|")
260             gerrit_comment="Document link(s):
261             $files"
262             echo
263             echo "$gerrit_comment"
264             echo
265             ssh -p 29418 gerrit.opnfv.org "gerrit review -p $GERRIT_PROJECT -m '$gerrit_comment' $GERRIT_PATCHSET_REVISION"
266
267 #TODO(r-mibu): change this to publisher
268 - builder:
269     name: remove-old-docs-from-opnfv-artifacts
270     builders:
271         - shell: |
272             #!/bin/bash -e
273             export PATH=$PATH:/usr/local/bin/
274
275             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
276
277             gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
278
279             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
280                 echo
281                 echo "Deleting Out-of-dated Documents..."
282                 gsutil -m rm -r "gs://$gs_path"
283             fi