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