Adds file-paths to verify
[releng.git] / jjb / apex / apex.yml
1 - project:
2     name: apex
3     jobs:
4         - 'apex-verify-{stream}'
5         - 'apex-merge-{stream}'
6         - 'apex-build-{stream}'
7         - 'apex-deploy-virtual-{stream}'
8         - 'apex-deploy-baremetal-{stream}'
9         - 'apex-daily-{stream}'
10
11     # stream:    branch with - in place of / (eg. stable-arno)
12     # branch:    branch (eg. stable/arno)
13     stream:
14         - master:
15             branch: 'master'
16             gs-pathname: ''
17
18     project: 'apex'
19
20 - job-template:
21     name: 'apex-verify-{stream}'
22
23     node: opnfv-jump-1
24
25     parameters:
26         - apex-parameter:
27             gs-pathname: '{gs-pathname}'
28         - project-parameter:
29             project: '{project}'
30         - gerrit-parameter:
31             branch: '{branch}'
32         - string:
33             name: GIT_BASE
34             default: https://gerrit.opnfv.org/gerrit/$PROJECT
35             description: "Used for overriding the GIT URL coming from parameters macro."
36
37     scm:
38         - gerrit-trigger-scm:
39             credentials-id: '{ssh-credentials}'
40             refspec: '$GERRIT_REFSPEC'
41             choosing-strategy: 'gerrit'
42
43     triggers:
44         - gerrit:
45             trigger-on:
46                 - patchset-created-event:
47                     exclude-drafts: 'false'
48                     exclude-trivial-rebase: 'false'
49                     exclude-no-code-change: 'false'
50                 - draft-published-event
51                 - comment-added-contains-event:
52                     comment-contains-value: 'recheck'
53                 - comment-added-contains-event:
54                     comment-contains-value: 'reverify'
55             projects:
56               - project-compare-type: 'ANT'
57                 project-pattern: 'apex'
58                 branches:
59                   - branch-compare-type: 'ANT'
60                     branch-pattern: '**/master'
61                 file-paths:
62                   - compare-type: ANT
63                     pattern: 'ci/**'
64                   - compare-type: ANT
65                     pattern: 'build/**'
66                   - compare-type: ANT
67                     pattern: 'lib/**'
68                   - compare-type: ANT
69                     pattern: 'config/**'
70                 forbidden-file-paths:
71                   - compare-type: ANT
72                     pattern: 'docs/**'
73
74     properties:
75         - build-blocker:
76             use-build-blocker: true
77             blocking-jobs:
78                 - "apex-daily.*"
79
80     builders:
81         - 'apex-build'
82         - 'apex-deploy-virtual'
83         - 'apex-workspace-cleanup'
84
85 - job-template:
86     name: 'apex-merge-{stream}'
87
88     # builder-merge job to run JJB update
89     #
90     # This job's purpose is to update all the JJB
91
92     node: opnfv-jump-1
93
94     disabled: true
95
96     parameters:
97         - apex-parameter:
98             gs-pathname: '{gs-pathname}'
99         - project-parameter:
100             project: '{project}'
101         - gerrit-parameter:
102             branch: '{branch}'
103         - string:
104             name: GIT_BASE
105             default: https://gerrit.opnfv.org/gerrit/$PROJECT
106             description: "Used for overriding the GIT URL coming from parameters macro."
107
108     scm:
109         - gerrit-trigger-scm:
110             credentials-id: '{ssh-credentials}'
111             refspec: ''
112             choosing-strategy: 'default'
113
114     triggers:
115         - gerrit:
116             trigger-on:
117                 - change-merged-event
118                 - comment-added-contains-event:
119                     comment-contains-value: 'remerge'
120             projects:
121               - project-compare-type: 'ANT'
122                 project-pattern: 'apex'
123                 branches:
124                     - branch-compare-type: 'ANT'
125                       branch-pattern: '**/master'
126                 forbidden-file-paths:
127                   - compare-type: ANT
128                     pattern: 'docs/**'
129
130     builders:
131         - 'apex-build'
132         - 'apex-deploy-virtual'
133         - 'apex-workspace-cleanup'
134
135 - job-template:
136     name: 'apex-build-{stream}'
137
138     # Job template for builds
139     #
140     # Required Variables:
141     #     stream:    branch with - in place of / (eg. stable)
142     #     branch:    branch (eg. stable)
143     node: opnfv-jump-1
144
145     disabled: false
146
147     parameters:
148         - project-parameter:
149             project: '{project}'
150         - apex-parameter:
151             gs-pathname: '{gs-pathname}'
152         - gerrit-parameter:
153             branch: '{branch}'
154         - string:
155             name: GIT_BASE
156             default: https://gerrit.opnfv.org/gerrit/$PROJECT
157             description: "Used for overriding the GIT URL coming from parameters macro."
158
159     scm:
160         - git-scm:
161             credentials-id: '{ssh-credentials}'
162             refspec: ''
163             branch: '{branch}'
164
165     builders:
166         - 'apex-build'
167         - 'apex-deploy-virtual'
168         - 'apex-upload-artifact'
169         - 'apex-workspace-cleanup'
170
171 - job-template:
172     name: 'apex-deploy-virtual-{stream}'
173
174     # Job template for virtual deployment
175     #
176     # Required Variables:
177     #     stream:    branch with - in place of / (eg. stable)
178     #     branch:    branch (eg. stable)
179     node: opnfv-jump-1
180
181     disabled: false
182
183     scm:
184         - git-scm:
185             credentials-id: '{ssh-credentials}'
186             refspec: ''
187             branch: '{branch}'
188
189     parameters:
190         - project-parameter:
191             project: '{project}'
192         - apex-parameter:
193             gs-pathname: '{gs-pathname}'
194
195     builders:
196         - 'apex-deploy-virtual'
197         - 'apex-workspace-cleanup'
198
199 - job-template:
200     name: 'apex-deploy-baremetal-{stream}'
201
202     # Job template for baremetal deployment
203     #
204     # Required Variables:
205     #     stream:    branch with - in place of / (eg. stable)
206     #     branch:    branch (eg. stable)
207     node: opnfv-jump-1
208
209     disabled: false
210
211     scm:
212         - git-scm:
213             credentials-id: '{ssh-credentials}'
214             refspec: ''
215             branch: '{branch}'
216
217     parameters:
218         - project-parameter:
219             project: '{project}'
220         - apex-parameter:
221             gs-pathname: '{gs-pathname}'
222
223     builders:
224         - 'apex-deploy-baremetal'
225         - 'apex-workspace-cleanup'
226
227 - job-template:
228     name: 'apex-daily-{stream}'
229
230     # Job template for daily build
231     #
232     # Required Variables:
233     #     stream:    branch with - in place of / (eg. stable)
234     #     branch:    branch (eg. stable)
235     node: opnfv-jump-1
236
237     disabled: false
238
239     scm:
240         - git-scm:
241             credentials-id: '{ssh-credentials}'
242             refspec: ''
243             branch: '{branch}'
244
245     parameters:
246         - project-parameter:
247             project: '{project}'
248         - apex-parameter:
249             gs-pathname: '{gs-pathname}'
250
251     properties:
252         - build-blocker:
253             use-build-blocker: true
254             blocking-jobs:
255                 - "apex-daily.*"
256
257     triggers:
258         - 'apex-{stream}'
259
260     builders:
261         - trigger-builds:
262           - project: 'apex-build-{stream}'
263             git-revision: true
264             block: true
265         - trigger-builds:
266           - project: 'apex-deploy-baremetal-{stream}'
267             git-revision: true
268             block: true
269         - trigger-builds:
270           - project: 'functest-apex-opnfv-jump-1-daily-{stream}'
271             block: true
272             block-thresholds:
273                 build-step-failure-threshold: 'never'
274                 failure-threshold: 'never'
275                 unstable-threshold: 'FAILURE'
276
277 ########################
278 # parameter macros
279 ########################
280 - parameter:
281     name: apex-parameter
282     parameters:
283         - string:
284             name: ARTIFACT_NAME
285             default: 'latest'
286             description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
287         - string:
288             name: BUILD_DIRECTORY
289             default: $WORKSPACE/build_output
290             description: "Directory where the build artifact will be located upon the completion of the build."
291         - string:
292             name: CACHE_DIRECTORY
293             default: $HOME/opnfv/cache/{gs-pathname}
294             description: "Directory where the cache to be used during the build is located."
295         - string:
296             name: GIT_BASE
297             default: https://gerrit.opnfv.org/gerrit/$PROJECT
298             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
299         - string:
300             name: GS_URL
301             default: artifacts.opnfv.org/$PROJECT/{gs-pathname}
302             description: "URL to Google Storage."
303
304 ########################
305 # builder macros
306 ########################
307 - builder:
308     name: 'apex-build'
309     builders:
310         - shell: |
311             #!/bin/bash
312             set -o errexit
313             set -o nounset
314             set -o pipefail
315             # log info to console
316             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
317             echo "---------------------------------------------------------------------------------------"
318             echo
319             # create the cache directory if it doesn't exist
320             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
321             # set OPNFV_ARTIFACT_VERSION
322             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
323             # start the build
324             cd $WORKSPACE/ci
325             ./build.sh -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
326             RPM_VERSION=$(grep Version $BUILD_DIRECTORY/../build/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
327             # list the contents of BUILD_OUTPUT directory
328             ls -al $BUILD_DIRECTORY
329             # save information regarding artifact into file
330             (
331                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
332                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
333                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
334                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
335                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
336                 echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
337                 echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
338                 echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
339                 echo "OPNFV_BUILD_URL=$BUILD_URL"
340             ) > $WORKSPACE/opnfv.properties
341             echo
342             echo "--------------------------------------------------------"
343
344 - builder:
345     name: 'apex-workspace-cleanup'
346     builders:
347         - shell: |
348             #!/bin/bash
349             set -o errexit
350             set -o nounset
351             set -o pipefail
352
353             # delete everything that is in $WORKSPACE
354             /bin/rm -rf $WORKSPACE
355
356 - builder:
357     name: 'apex-upload-artifact'
358     builders:
359         - shell: |
360             #!/bin/bash
361             set -o errexit
362             set -o nounset
363             set -o pipefail
364
365             # log info to console
366             echo "Uploading the Apex artifact. This could take some time..."
367             echo "--------------------------------------------------------"
368             echo
369
370             # source the opnfv.properties to get ARTIFACT_VERSION
371             source $WORKSPACE/opnfv.properties
372
373             # upload artifact and additional files to google storage
374             gsutil cp $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
375             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL) gs://$GS_URL/$(basename $OPNFV_RPM_URL) > gsutil.iso.log 2>&1
376             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_SRPM_URL) gs://$GS_URL/$(basename $OPNFV_SRPM_URL) > gsutil.iso.log 2>&1
377             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
378             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
379
380             echo
381             echo "--------------------------------------------------------"
382             echo "Done!"
383             echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
384             echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
385
386 - builder:
387     name: 'apex-deploy-virtual'
388     builders:
389         - shell: |
390             #!/bin/bash
391             set -o errexit
392             set -o nounset
393             set -o pipefail
394
395             # log info to console
396             echo "Starting the Apex virtual deployment."
397             echo "--------------------------------------------------------"
398             echo
399
400             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
401                 # if artifact name is passed the pull a
402                 # specific artifact from artifacts.opnfv.org
403                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
404             else
405                 if [[ -f opnfv.properties ]]; then
406                     # if opnfv.properties exists then use the
407                     # local build. Source the file so we get local OPNFV vars
408                     source opnfv.properties
409                     RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
410                 else
411                     # no opnfv.properties means use the latest from artifacts.opnfv.org
412                     # get the latest.properties to get the link to the latest artifact
413                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
414                     [[ -f opnfv.properties ]] || exit 1
415                     # source the file so we get OPNFV vars
416                     source opnfv.properties
417                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
418                 fi
419             fi
420
421             source opnfv.properties
422             RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
423
424             # update / install the new rpm
425             if rpm -q opnfv-apex > /dev/null; then
426                if sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
427                    sudo yum downgrade -y $RPM_INSTALL_PATH;
428                fi
429             else
430                sudo yum install -y $RPM_INSTALL_PATH;
431             fi
432
433             # cleanup virtual machines before we start
434             sudo opnfv-clean
435             # initiate virtual deployment
436             if [ -e /usr/share/doc/opnfv/network_settings.yaml.example ]; then
437               sudo opnfv-deploy -v -d /usr/share/doc/opnfv/deploy_settings.yaml.example -n /usr/share/doc/opnfv/network_settings.yaml.example
438             else
439               sudo opnfv-deploy -v
440             fi
441             echo
442             echo "--------------------------------------------------------"
443             echo "Done!"
444
445 - builder:
446     name: 'apex-deploy-baremetal'
447     builders:
448         - shell: |
449             #!/bin/bash
450             set -o errexit
451             set -o nounset
452             set -o pipefail
453
454             # log info to console
455             echo "Starting the Apex baremetal deployment."
456             echo "--------------------------------------------------------"
457             echo
458
459             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
460                 # if artifact name is passed the pull a
461                 # specific artifact from artifacts.opnfv.org
462                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
463             else
464                 if [[ -f opnfv.properties ]]; then
465                     # if opnfv.properties exists then use the
466                     # local build. Source the file so we get local OPNFV vars
467                     source opnfv.properties
468                     RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
469                 else
470                     # no opnfv.properties means use the latest from artifacts.opnfv.org
471                     # get the latest.properties to get the link to the latest artifact
472                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
473                     [[ -f opnfv.properties ]] || exit 1
474                     # source the file so we get OPNFV vars
475                     source opnfv.properties
476                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
477                 fi
478             fi
479
480             source opnfv.properties
481             RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
482             if [ ! -e "$RPM_INSTALL_PATH" ]; then
483                RPM_INSTALL_PATH=http://${OPNFV_RPM_URL}
484             fi
485
486             # update / install the new rpm
487             if rpm -q opnfv-apex > /dev/null; then
488                if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
489                  echo "RPM is already installed"
490                elif sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
491                    sudo yum downgrade -y $RPM_INSTALL_PATH;
492                fi
493             else
494                sudo yum install -y $RPM_INSTALL_PATH;
495             fi
496
497             # cleanup environment before we start
498             sudo opnfv-clean
499             # initiate baremetal deployment
500             sudo opnfv-deploy -i  /root/inventory/pod_settings.yaml \
501             -d /usr/share/doc/opnfv/deploy_settings.yaml.example \
502             -n /root/network/network_settings.yaml
503
504             echo
505             echo "--------------------------------------------------------"
506             echo "Done!"
507
508 #######################
509 # trigger macros
510 ########################
511 - trigger:
512     name: 'apex-master'
513     triggers:
514         - timed: '0 3 * * *'