Apex: fix rpm latest path
[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.opnfv.org/$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             timeout: 15
51
52 - wrapper:
53     name: build-timeout
54     wrappers:
55         - timeout:
56             type: absolute
57             timeout: 360
58             fail: true
59
60 - trigger:
61     name: 'daily-trigger-disabled'
62     triggers:
63         - timed: ''
64
65 - trigger:
66     name: 'weekly-trigger-disabled'
67     triggers:
68         - timed: ''
69
70 - trigger:
71     name: 'brahmaputra-trigger-daily-enabled'
72     triggers:
73         - timed: '0 2 * * *'
74
75 - trigger:
76     name: gerrit-trigger-patch-submitted
77     triggers:
78         - gerrit:
79             server-name: 'gerrit.opnfv.org'
80             trigger-on:
81                 - patchset-created-event:
82                     exclude-drafts: 'false'
83                     exclude-trivial-rebase: 'false'
84                     exclude-no-code-change: 'false'
85                 - draft-published-event
86                 - comment-added-contains-event:
87                     comment-contains-value: 'recheck'
88             projects:
89               - project-compare-type: 'ANT'
90                 project-pattern: '{name}'
91                 branches:
92                   - branch-compare-type: 'ANT'
93                     branch-pattern: '**/{branch}'
94
95 - trigger:
96     name: gerrit-trigger-patch-merged
97     triggers:
98         - gerrit:
99             server-name: 'gerrit.opnfv.org'
100             trigger-on:
101                 - change-merged-event
102                 - comment-added-contains-event:
103                     comment-contains-value: 'remerge'
104             projects:
105               - project-compare-type: 'ANT'
106                 project-pattern: '{name}'
107                 branches:
108                   - branch-compare-type: 'ANT'
109                     branch-pattern: '**/{branch}'
110
111 - publisher:
112     name: archive-artifacts
113     publishers:
114         - archive:
115             artifacts: '{artifacts}'
116             allow-empty: true
117             fingerprint: true
118             latest-only: true
119
120 - publisher:
121     name: email-notification
122     publishers:
123         - email-ext:
124             recipients: 'jenkins@lists.opnfv.org'
125             reply-to:
126             content-type: default
127             subject: '{email-prefix} $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!'
128             body: |
129                 $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
130
131                 Check console output at $BUILD_URL to view the results.
132             unstable: true
133             fixed: true
134             send-to:
135                 - developers
136                 - recipients
137
138 - publisher:
139         name: jacoco-report
140         publishers:
141             - jacoco:
142                 exec-pattern: "**/**.exec"
143                 class-pattern: "**/classes"
144                 source-pattern: "**/src/main/java"
145                 exclusion-pattern: "**/gen/**,**/generated-sources/**,**/yang-gen**"
146                 status-update: true
147                 targets:
148                   - branch:
149                       healthy: 10
150                       unhealthy: 20
151                   - method:
152                       healthy: 50
153                       unhealthy: 40
154
155
156 - builder:
157     name: test-macro
158     builders:
159         - shell: 'echo testing macro "test-macro"'
160
161 - builder:
162     name: wipe-org-opendaylight-repo
163     builders:
164         - shell: 'if [ -d /tmp/r/org/opendaylight ]; then rm -rf /tmp/r/org/opendaylight; fi'
165
166 - builder:
167     name: jacoco-nojava-workaround
168     builders:
169         - shell: 'mkdir -p $WORKSPACE/target/classes'
170
171
172 # New Releng macros
173
174 - builder:
175     name: build-html-and-pdf-docs-output
176     builders:
177         - shell: |
178             #!/bin/bash
179             set -o errexit
180             set -o xtrace
181             export PATH=$PATH:/usr/local/bin/
182             git clone ssh://gerrit.opnfv.org:29418/opnfvdocs docs_build/_opnfvdocs
183             GERRIT_COMMENT=gerrit_comment.txt ./docs_build/_opnfvdocs/scripts/docs-build.sh
184
185 - builder:
186     name: upload-under-review-docs-to-opnfv-artifacts
187     builders:
188         - shell: |
189             #!/bin/bash
190             set -o errexit
191             set -o pipefail
192             set -o xtrace
193             export PATH=$PATH:/usr/local/bin/
194
195             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
196             [[ -d docs_output ]] || exit 0
197
198             echo
199             echo "###########################"
200             echo "UPLOADING DOCS UNDER REVIEW"
201             echo "###########################"
202             echo
203
204             gs_base="artifacts.opnfv.org/$PROJECT/review"
205             gs_path="$gs_base/$GERRIT_CHANGE_NUMBER"
206             local_path="upload/$GERRIT_CHANGE_NUMBER"
207
208             mkdir -p upload
209             mv docs_output "$local_path"
210             gsutil -m cp -r "$local_path" "gs://$gs_base"
211
212             gsutil -m setmeta \
213                 -h "Content-Type:text/html" \
214                 -h "Cache-Control:private, max-age=0, no-transform" \
215                 "gs://$gs_path"/**.html > /dev/null 2>&1
216
217             echo "Document link(s):" >> gerrit_comment.txt
218             find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
219                 sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
220
221 - builder:
222     name: upload-generated-docs-to-opnfv-artifacts
223     builders:
224         - shell: |
225             #!/bin/bash
226             set -o errexit
227             set -o pipefail
228             set -o xtrace
229             export PATH=$PATH:/usr/local/bin/
230
231             [[ -d docs_output ]] || exit 0
232
233             echo
234             echo "########################"
235             echo "UPLOADING GENERATED DOCS"
236             echo "########################"
237             echo
238
239             gs_path="$GS_URL/docs"
240             local_path="upload/docs"
241
242             mkdir -p upload
243             mv docs_output "$local_path"
244             gsutil -m cp -r "$local_path" "gs://$GS_URL"
245
246             gsutil -m setmeta \
247                 -h "Content-Type:text/html" \
248                 -h "Cache-Control:private, max-age=0, no-transform" \
249                 "gs://$gs_path"/**.html > /dev/null 2>&1
250
251             echo "Document link(s):" >> gerrit_comment.txt
252             find "$local_path" | grep -e 'index.html$' -e 'pdf$' | \
253                 sed -e "s|^$local_path|    http://$gs_path|" >> gerrit_comment.txt
254
255 - builder:
256     name: report-docs-build-result-to-gerrit
257     builders:
258         - shell: |
259             #!/bin/bash
260             set -o errexit
261             set -o pipefail
262             set -o xtrace
263             export PATH=$PATH:/usr/local/bin/
264             if [[ -e gerrit_comment.txt ]] ; then
265                 echo
266                 echo "posting review comment to gerrit..."
267                 echo
268                 cat gerrit_comment.txt
269                 echo
270                 ssh -p 29418 gerrit.opnfv.org \
271                     "gerrit review -p $GERRIT_PROJECT \
272                      -m '$(cat gerrit_comment.txt)' \
273                      $GERRIT_PATCHSET_REVISION \
274                      --notify NONE"
275             fi
276
277 - builder:
278     name: remove-old-docs-from-opnfv-artifacts
279     builders:
280         - shell: |
281             #!/bin/bash
282             set -o errexit
283             set -o pipefail
284             set -o xtrace
285             export PATH=$PATH:/usr/local/bin/
286
287             [[ $GERRIT_CHANGE_NUMBER =~ .+ ]]
288
289             gs_path="artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
290
291             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
292                 echo
293                 echo "Deleting Out-of-dated Documents..."
294                 gsutil -m rm -r "gs://$gs_path"
295             fi
296             gs_path="artifacts.opnfv.org/review/$GERRIT_CHANGE_NUMBER"
297
298             if gsutil ls "gs://$gs_path" > /dev/null 2>&1 ; then
299                 echo
300                 echo "Deleting Out-of-dated Documents..."
301                 gsutil -m rm -r "gs://$gs_path"
302             fi
303
304 - builder:
305     name: build-and-upload-artifacts-json-api
306     builders:
307         - shell: |
308             #!/bin/bash
309             set -o errexit
310             set -o pipefail
311             export PATH=$PATH:/usr/local/bin/
312
313             virtualenv -p python2.7 $WORKSPACE/releng_artifacts
314             source $WORKSPACE/releng_artifacts/bin/activate
315
316             # install python packages
317             pip install google-api-python-client
318
319             # generate and upload index file
320             echo "Generating Artifacts API ..."
321             python $WORKSPACE/utils/opnfv-artifacts.py > index.json
322             gsutil cp index.json gs://artifacts.opnfv.org/index.json
323
324             deactivate
325
326 - builder:
327     name: lint-python-code
328     builders:
329         - shell: |
330             #!/bin/bash
331             set -o errexit
332             set -o pipefail
333             set -o xtrace
334             export PATH=$PATH:/usr/local/bin/
335
336             virtualenv -p python2.7 $WORKSPACE/releng_flake8
337             source $WORKSPACE/releng_flake8/bin/activate
338
339             # install python packages
340             pip install "flake8==2.6.2"
341
342             # generate and upload lint log
343             echo "Running flake8 code on $PROJECT ..."
344
345             # Get number of flake8 violations. If none, this will be an
346             # empty string: ""
347             FLAKE_COUNT="$(find . \
348                 -path './releng_flake8' -prune -o \
349                 -path './.tox' -prune -o \
350                 -type f -name "*.py" -print | \
351                 xargs flake8 --exit-zero -qq --count 2>&1)"
352
353             # Ensure we start with a clean environment
354             rm -f lint.log
355
356             if [ ! -z $FLAKE_COUNT ]; then
357               echo "Flake8 Violations: $FLAKE_COUNT" > lint.log
358               find . \
359                   -path './releng_flake8' -prune -o \
360                   -path './.tox' -prune -o \
361                   -type f -name "*.py" -print | \
362                   xargs flake8 --exit-zero --first >> violation.log
363               SHOWN=$(wc -l violation.log | cut -d' ' -f1)
364               echo -e "First $SHOWN shown\n---" >> lint.log
365               cat violation.log >> lint.log
366               sed -r -i '4,$s/^/ /g' lint.log
367               rm violation.log
368             fi
369
370             deactivate
371
372 - builder:
373     name: report-lint-result-to-gerrit
374     builders:
375         - shell: |
376             #!/bin/bash
377             set -o errexit
378             set -o pipefail
379             set -o xtrace
380             export PATH=$PATH:/usr/local/bin/
381
382             # If no violations were found, no lint log will exist.
383             if [[ -e lint.log ]] ; then
384                 echo -e "\nposting linting report to gerrit...\n"
385
386                 cat lint.log
387                 echo
388
389                 ssh -p 29418 gerrit.opnfv.org \
390                     "gerrit review -p $GERRIT_PROJECT \
391                      -m \"$(cat lint.log)\" \
392                      $GERRIT_PATCHSET_REVISION \
393                      --notify NONE"
394
395                 exit 1
396             fi
397
398 - builder:
399     name: upload-review-docs
400     builders:
401         - build-html-and-pdf-docs-output
402         - upload-under-review-docs-to-opnfv-artifacts
403         - report-docs-build-result-to-gerrit
404
405 - builder:
406     name: upload-merged-docs
407     builders:
408         - build-html-and-pdf-docs-output
409         - upload-generated-docs-to-opnfv-artifacts
410         - report-docs-build-result-to-gerrit
411         - remove-old-docs-from-opnfv-artifacts
412
413 - builder:
414     name: check-bash-syntax
415     builders:
416         - shell: "find . -name '*.sh' | xargs bash -n"