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