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