Making sure the BUILD_ARGS are set right for Apex daily
[releng.git] / jjb / apex / apex.yml
1 - project:
2     name: apex
3     jobs:
4         - 'apex-verify-{stream1}'
5         - 'apex-verify-{stream2}'
6         - 'apex-runner-{platform}-{scenario}-{stream}'
7         - 'apex-build-{stream}'
8         - 'apex-deploy-virtual-{scenario}-{stream}'
9         - 'apex-deploy-baremetal-{scenario}-{stream}'
10         - 'apex-daily-{stream1}'
11         - 'apex-daily-{stream2}'
12
13     # stream:    branch with - in place of / (eg. stable-arno)
14     # branch:    branch (eg. stable/arno)
15     stream:
16         - master:
17             branch: 'master'
18             gs-pathname: ''
19             block-stream: 'brahmaputra'
20             slave: 'intel-pod7'
21         - brahmaputra:
22             branch: 'stable/brahmaputra'
23             gs-pathname: '/brahmaputra'
24             block-stream: 'master'
25             slave: 'opnfv-jump-1'
26             disabled: false
27
28     stream1:
29         - master:
30             branch: 'master'
31             gs-pathname: ''
32             block-stream: 'brahmaputra'
33             slave: 'intel-pod7'
34
35     stream2:
36         - brahmaputra:
37             branch: 'stable/brahmaputra'
38             gs-pathname: '/brahmaputra'
39             block-stream: 'master'
40             slave: 'opnfv-jump-1'
41             disabled: false
42
43     project: 'apex'
44
45     scenario:
46          - 'os-nosdn-nofeature-ha'
47          - 'os-odl_l2-nofeature-ha'
48          - 'os-odl_l2-sfc-noha'
49          - 'os-odl_l3-nofeature-ha'
50          - 'os-onos-nofeature-ha'
51          - 'os-opencontrail-nofeature-ha'
52
53     platform:
54          - 'baremetal'
55          - 'virtual'
56
57 # Brahmaputra Verify
58 - job-template:
59     name: 'apex-verify-{stream2}'
60
61     node: '{slave}'
62
63     parameters:
64         - apex-parameter:
65             gs-pathname: '{gs-pathname}'
66         - project-parameter:
67             project: '{project}'
68         - gerrit-parameter:
69             branch: '{branch}'
70         - string:
71             name: GIT_BASE
72             default: https://gerrit.opnfv.org/gerrit/$PROJECT
73             description: "Used for overriding the GIT URL coming from parameters macro."
74
75     scm:
76         - gerrit-trigger-scm:
77             credentials-id: '{ssh-credentials}'
78             refspec: '$GERRIT_REFSPEC'
79             choosing-strategy: 'gerrit'
80
81     triggers:
82         - gerrit:
83             trigger-on:
84                 - patchset-created-event:
85                     exclude-drafts: 'false'
86                     exclude-trivial-rebase: 'false'
87                     exclude-no-code-change: 'true'
88                 - draft-published-event
89                 - comment-added-contains-event:
90                     comment-contains-value: 'recheck'
91                 - comment-added-contains-event:
92                     comment-contains-value: 'reverify'
93             projects:
94               - project-compare-type: 'ANT'
95                 project-pattern: 'apex'
96                 branches:
97                   - branch-compare-type: 'ANT'
98                     branch-pattern: '**/{branch}'
99                 file-paths:
100                   - compare-type: ANT
101                     pattern: 'ci/**'
102                   - compare-type: ANT
103                     pattern: 'build/**'
104                   - compare-type: ANT
105                     pattern: 'lib/**'
106                   - compare-type: ANT
107                     pattern: 'config/**'
108
109     properties:
110         - build-blocker:
111             use-build-blocker: true
112             blocking-jobs:
113                 - 'apex-daily.*{stream2}'
114                 - 'apex-deploy.*{stream2}'
115                 - 'apex-build.*{stream2}'
116                 - 'apex-runner.*{stream2}'
117                 - 'apex-verify-{stream2}'
118
119     builders:
120         - 'apex-build'
121         - trigger-builds:
122           - project: 'apex-deploy-virtual-os-odl_l2-nofeature-ha-{stream2}'
123             predefined-parameters: |
124               BUILD_DIRECTORY=apex-verify-{stream2}/build_output
125               OPNFV_CLEAN=yes
126             git-revision: false
127             block: true
128         - trigger-builds:
129           - project: 'apex-deploy-virtual-os-onos-nofeature-ha-{stream2}'
130             predefined-parameters: |
131               BUILD_DIRECTORY=apex-verify-{stream2}/build_output
132               OPNFV_CLEAN=yes
133             git-revision: false
134             block: true
135         - trigger-builds:
136           - project: 'apex-deploy-virtual-os-odl_l3-nofeature-ha-{stream2}'
137             predefined-parameters: |
138               BUILD_DIRECTORY=apex-verify-{stream2}/build_output
139               OPNFV_CLEAN=yes
140             git-revision: false
141             block: true
142         - trigger-builds:
143           - project: 'apex-deploy-virtual-os-odl_l2-sfc-noha-{stream2}'
144             predefined-parameters: |
145               BUILD_DIRECTORY=apex-verify-{stream2}/build_output
146               OPNFV_CLEAN=yes
147             git-revision: false
148             block: true
149         - 'apex-workspace-cleanup'
150
151 # Master Verify
152 - job-template:
153     name: 'apex-verify-{stream1}'
154
155     node: '{slave}'
156
157     parameters:
158         - apex-parameter:
159             gs-pathname: '{gs-pathname}'
160         - project-parameter:
161             project: '{project}'
162         - gerrit-parameter:
163             branch: '{branch}'
164         - string:
165             name: GIT_BASE
166             default: https://gerrit.opnfv.org/gerrit/$PROJECT
167             description: "Used for overriding the GIT URL coming from parameters macro."
168
169     scm:
170         - gerrit-trigger-scm:
171             credentials-id: '{ssh-credentials}'
172             refspec: '$GERRIT_REFSPEC'
173             choosing-strategy: 'gerrit'
174
175     triggers:
176         - gerrit:
177             trigger-on:
178                 - patchset-created-event:
179                     exclude-drafts: 'false'
180                     exclude-trivial-rebase: 'false'
181                     exclude-no-code-change: 'true'
182                 - draft-published-event
183                 - comment-added-contains-event:
184                     comment-contains-value: 'recheck'
185                 - comment-added-contains-event:
186                     comment-contains-value: 'reverify'
187             projects:
188               - project-compare-type: 'ANT'
189                 project-pattern: 'apex'
190                 branches:
191                   - branch-compare-type: 'ANT'
192                     branch-pattern: '**/{branch}'
193                 file-paths:
194                   - compare-type: ANT
195                     pattern: 'ci/**'
196                   - compare-type: ANT
197                     pattern: 'build/**'
198                   - compare-type: ANT
199                     pattern: 'lib/**'
200                   - compare-type: ANT
201                     pattern: 'config/**'
202
203     properties:
204         - build-blocker:
205             use-build-blocker: true
206             blocking-jobs:
207                 - 'apex-daily.*{stream1}'
208                 - 'apex-deploy.*{stream1}'
209                 - 'apex-build.*{stream1}'
210                 - 'apex-runner.*{stream1}'
211                 - 'apex-verify-{stream1}'
212
213     builders:
214         - 'apex-build'
215         - trigger-builds:
216           - project: 'apex-deploy-virtual-os-nosdn-nofeature-ha-{stream1}'
217             predefined-parameters: |
218               BUILD_DIRECTORY=apex-verify-{stream1}/build_output
219               OPNFV_CLEAN=yes
220             git-revision: false
221             block: true
222         - 'apex-workspace-cleanup'
223
224 - job-template:
225     name: 'apex-runner-{platform}-{scenario}-{stream}'
226
227     # runner jobs for deploying manually
228
229     node: '{slave}'
230
231     disabled: false
232
233     parameters:
234         - apex-parameter:
235             gs-pathname: '{gs-pathname}'
236         - project-parameter:
237             project: '{project}'
238         - gerrit-parameter:
239             branch: '{branch}'
240         - string:
241             name: GIT_BASE
242             default: https://gerrit.opnfv.org/gerrit/$PROJECT
243             description: "Used for overriding the GIT URL coming from parameters macro."
244
245     scm:
246         - gerrit-trigger-scm:
247             credentials-id: '{ssh-credentials}'
248             refspec: ''
249             choosing-strategy: 'default'
250
251     properties:
252         - build-blocker:
253             use-build-blocker: true
254             blocking-jobs:
255                 - 'apex-daily.*{stream}'
256                 - 'apex-verify.*{stream}'
257
258     builders:
259         - trigger-builds:
260           - project: 'apex-deploy-{platform}-{scenario}-{stream}'
261             predefined-parameters:
262               OPNFV_CLEAN=yes
263             git-revision: false
264             block: true
265         - trigger-builds:
266           - project: 'yardstick-apex-{slave}-daily-{stream}'
267             predefined-parameters:
268               DEPLOY_SCENARIO={scenario}
269             block: true
270             block-thresholds:
271                 build-step-failure-threshold: 'never'
272                 failure-threshold: 'never'
273                 unstable-threshold: 'FAILURE'
274         - trigger-builds:
275           - project: 'functest-apex-{slave}-daily-{stream}'
276             predefined-parameters:
277               DEPLOY_SCENARIO={scenario}
278             block: true
279             block-thresholds:
280                 build-step-failure-threshold: 'never'
281                 failure-threshold: 'never'
282                 unstable-threshold: 'FAILURE'
283
284 - job-template:
285     name: 'apex-build-{stream}'
286
287     # Job template for builds
288     #
289     # Required Variables:
290     #     stream:    branch with - in place of / (eg. stable)
291     #     branch:    branch (eg. stable)
292     node: '{slave}'
293
294     disabled: false
295
296     parameters:
297         - project-parameter:
298             project: '{project}'
299         - apex-parameter:
300             gs-pathname: '{gs-pathname}'
301         - gerrit-parameter:
302             branch: '{branch}'
303         - string:
304             name: GIT_BASE
305             default: https://gerrit.opnfv.org/gerrit/$PROJECT
306             description: "Used for overriding the GIT URL coming from parameters macro."
307
308     scm:
309         - git-scm:
310             credentials-id: '{ssh-credentials}'
311             refspec: ''
312             branch: '{branch}'
313
314     properties:
315         - build-blocker:
316             use-build-blocker: true
317             blocking-jobs:
318                 - 'apex-deploy.*{stream}'
319
320     builders:
321         - 'apex-build'
322         - trigger-builds:
323           - project: 'apex-deploy-virtual-os-nosdn-nofeature-ha-{stream}'
324             predefined-parameters: |
325               BUILD_DIRECTORY=apex-build-{stream}/build_output
326               OPNFV_CLEAN=yes
327             git-revision: false
328             block: true
329         - 'apex-upload-artifact'
330
331 - job-template:
332     name: 'apex-deploy-virtual-{scenario}-{stream}'
333
334     # Job template for virtual deployment
335     #
336     # Required Variables:
337     #     stream:    branch with - in place of / (eg. stable)
338     #     branch:    branch (eg. stable)
339     node: '{slave}'
340
341     disabled: false
342
343     scm:
344         - git-scm:
345             credentials-id: '{ssh-credentials}'
346             refspec: ''
347             branch: '{branch}'
348
349     parameters:
350         - project-parameter:
351             project: '{project}'
352         - apex-parameter:
353             gs-pathname: '{gs-pathname}'
354         - string:
355             name: DEPLOY_SCENARIO
356             default: '{scenario}'
357             description: "Scenario to deploy with."
358         - string:
359             name: OPNFV_CLEAN
360             default: 'no'
361             description: "Use yes in lower case to invoke clean. Indicates if the deploy environment should be cleaned before deployment"
362
363     properties:
364         - build-blocker:
365             use-build-blocker: true
366             blocking-jobs:
367                 - 'apex-deploy.*{stream}'
368
369     builders:
370         - 'apex-deploy-virtual'
371         - 'apex-workspace-cleanup'
372
373 - job-template:
374     name: 'apex-deploy-baremetal-{scenario}-{stream}'
375
376     # Job template for baremetal deployment
377     #
378     # Required Variables:
379     #     stream:    branch with - in place of / (eg. stable)
380     #     branch:    branch (eg. stable)
381     node: '{slave}'
382
383     disabled: false
384
385     scm:
386         - git-scm:
387             credentials-id: '{ssh-credentials}'
388             refspec: ''
389             branch: '{branch}'
390
391     parameters:
392         - project-parameter:
393             project: '{project}'
394         - apex-parameter:
395             gs-pathname: '{gs-pathname}'
396         - string:
397             name: DEPLOY_SCENARIO
398             default: '{scenario}'
399             description: "Scenario to deploy with."
400
401     properties:
402         - build-blocker:
403             use-build-blocker: true
404             blocking-jobs:
405                 - 'apex-verify.*{stream}'
406                 - 'apex-deploy.*{stream}'
407                 - 'apex-build.*{stream}'
408
409
410     builders:
411         - 'apex-deploy-baremetal'
412         - 'apex-workspace-cleanup'
413
414 # Brahmaputra Daily
415 - job-template:
416     name: 'apex-daily-{stream2}'
417
418     # Job template for daily build
419     #
420     # Required Variables:
421     #     stream:    branch with - in place of / (eg. stable)
422     #     branch:    branch (eg. stable)
423     node: '{slave}'
424
425     disabled: false
426
427     scm:
428         - git-scm:
429             credentials-id: '{ssh-credentials}'
430             refspec: ''
431             branch: '{branch}'
432
433     parameters:
434         - project-parameter:
435             project: '{project}'
436         - apex-parameter:
437             gs-pathname: '{gs-pathname}'
438
439     properties:
440         - build-blocker:
441             use-build-blocker: true
442             blocking-jobs:
443                 - 'apex-verify.*{stream2}'
444                 - 'apex-deploy.*{stream2}'
445                 - 'apex-build.*{stream2}'
446                 - 'apex-runner.*{stream2}'
447
448     triggers:
449         - 'apex-{stream2}'
450
451     builders:
452         - trigger-builds:
453           - project: 'apex-build-{stream2}'
454             git-revision: true
455             current-parameters: true
456             block: true
457         - trigger-builds:
458           - project: 'apex-deploy-baremetal-os-odl_l2-nofeature-ha-{stream2}'
459             predefined-parameters: |
460               BUILD_DIRECTORY=apex-build-{stream2}/build_output
461               OPNFV_CLEAN=yes
462             git-revision: true
463             block: true
464         - trigger-builds:
465           - project: 'functest-apex-{slave}-daily-{stream2}'
466             predefined-parameters:
467               DEPLOY_SCENARIO=os-odl_l2-nofeature-ha
468             block: true
469             block-thresholds:
470                 build-step-failure-threshold: 'never'
471                 failure-threshold: 'never'
472                 unstable-threshold: 'FAILURE'
473         - trigger-builds:
474           - project: 'yardstick-apex-{slave}-daily-{stream2}'
475             predefined-parameters:
476               DEPLOY_SCENARIO=os-odl_l2-nofeature-ha
477             block: true
478             block-thresholds:
479                 build-step-failure-threshold: 'never'
480                 failure-threshold: 'never'
481                 unstable-threshold: 'FAILURE'
482         - trigger-builds:
483           - project: 'apex-deploy-baremetal-os-onos-nofeature-ha-{stream2}'
484             predefined-parameters:
485               BUILD_DIRECTORY=apex-build-{stream2}/build_output
486             git-revision: true
487             block: true
488         - trigger-builds:
489           - project: 'functest-apex-{slave}-daily-{stream2}'
490             predefined-parameters:
491               DEPLOY_SCENARIO=os-onos-nofeature-ha
492             block: true
493             block-thresholds:
494                 build-step-failure-threshold: 'never'
495                 failure-threshold: 'never'
496                 unstable-threshold: 'FAILURE'
497         - trigger-builds:
498           - project: 'yardstick-apex-{slave}-daily-{stream2}'
499             predefined-parameters:
500               DEPLOY_SCENARIO=os-onos-nofeature-ha
501             block: true
502             block-thresholds:
503                 build-step-failure-threshold: 'never'
504                 failure-threshold: 'never'
505                 unstable-threshold: 'FAILURE'
506         - trigger-builds:
507           - project: 'apex-deploy-baremetal-os-odl_l3-nofeature-ha-{stream2}'
508             predefined-parameters:
509               BUILD_DIRECTORY=apex-build-{stream2}/build_output
510             git-revision: true
511             block: true
512         - trigger-builds:
513           - project: 'functest-apex-{slave}-daily-{stream2}'
514             predefined-parameters:
515               DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
516             block: true
517             block-thresholds:
518                 build-step-failure-threshold: 'never'
519                 failure-threshold: 'never'
520                 unstable-threshold: 'FAILURE'
521         - trigger-builds:
522           - project: 'yardstick-apex-{slave}-daily-{stream2}'
523             predefined-parameters:
524               DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
525             block: true
526             block-thresholds:
527                 build-step-failure-threshold: 'never'
528                 failure-threshold: 'never'
529                 unstable-threshold: 'FAILURE'
530
531 # Master Daily
532 - job-template:
533     name: 'apex-daily-{stream1}'
534
535     # Job template for daily build
536     #
537     # Required Variables:
538     #     stream:    branch with - in place of / (eg. stable)
539     #     branch:    branch (eg. stable)
540     node: '{slave}'
541
542     disabled: false
543
544     scm:
545         - git-scm:
546             credentials-id: '{ssh-credentials}'
547             refspec: ''
548             branch: '{branch}'
549
550     parameters:
551         - project-parameter:
552             project: '{project}'
553         - apex-parameter:
554             gs-pathname: '{gs-pathname}'
555
556     properties:
557         - build-blocker:
558             use-build-blocker: true
559             blocking-jobs:
560                 - 'apex-verify.*{stream1}'
561                 - 'apex-deploy.*{stream1}'
562                 - 'apex-build.*{stream1}'
563                 - 'apex-runner.*{stream1}'
564
565     triggers:
566         - 'apex-{stream1}'
567
568     builders:
569         - trigger-builds:
570           - project: 'apex-build-{stream1}'
571             git-revision: true
572             current-parameters: true
573             block: true
574         - trigger-builds:
575           - project: 'apex-deploy-virtual-nosdn-nofeature-ha-{stream1}'
576             predefined-parameters: |
577               BUILD_DIRECTORY=apex-build-{stream1}/build_output
578               OPNFV_CLEAN=yes
579             git-revision: true
580             block: true
581         - trigger-builds:
582           - project: 'functest-apex-{slave}-daily-{stream1}'
583             predefined-parameters:
584               DEPLOY_SCENARIO=os-nosdn-nofeature-ha
585             block: true
586             block-thresholds:
587                 build-step-failure-threshold: 'never'
588                 failure-threshold: 'never'
589                 unstable-threshold: 'FAILURE'
590         - trigger-builds:
591           - project: 'yardstick-apex-{slave}-daily-{stream1}'
592             predefined-parameters:
593               DEPLOY_SCENARIO=os-nosdn-nofeature-ha
594             block: true
595             block-thresholds:
596                 build-step-failure-threshold: 'never'
597                 failure-threshold: 'never'
598                 unstable-threshold: 'FAILURE'
599
600 ########################
601 # parameter macros
602 ########################
603 - parameter:
604     name: apex-parameter
605     parameters:
606         - string:
607             name: ARTIFACT_NAME
608             default: 'latest'
609             description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
610         - string:
611             name: ARTIFACT_VERSION
612             default: 'daily'
613             description: "Artifact version type"
614         - string:
615             name: BUILD_DIRECTORY
616             default: $WORKSPACE/build_output
617             description: "Directory where the build artifact will be located upon the completion of the build."
618         - string:
619             name: CACHE_DIRECTORY
620             default: $HOME/opnfv/cache{gs-pathname}
621             description: "Directory where the cache to be used during the build is located."
622         - string:
623             name: GIT_BASE
624             default: https://gerrit.opnfv.org/gerrit/$PROJECT
625             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
626         - string:
627             name: GS_URL
628             default: artifacts.opnfv.org/$PROJECT{gs-pathname}
629             description: "URL to Google Storage."
630
631 ########################
632 # builder macros
633 ########################
634 - builder:
635     name: 'apex-build'
636     builders:
637         - shell: |
638             #!/bin/bash
639             set -o errexit
640             set -o nounset
641             set -o pipefail
642             # log info to console
643             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
644             echo "---------------------------------------------------------------------------------------"
645             echo
646             # create the cache directory if it doesn't exist
647             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
648             # set OPNFV_ARTIFACT_VERSION
649             if echo $BUILD_TAG | grep "apex-verify" 1> /dev/null; then
650               if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
651                 export OPNFV_ARTIFACT_VERSION=brahmaputra-dev${BUILD_NUMBER}
652                 export BUILD_ARGS="-v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY"
653               else
654                 export OPNFV_ARTIFACT_VERSION=dev${BUILD_NUMBER}
655                 export BUILD_ARGS="-r $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY"
656               fi
657             elif [ "$ARTIFACT_VERSION" == "daily" ]; then
658               if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
659                 export OPNFV_ARTIFACT_VERSION=brahmaputra-$(date -u +"%Y-%m-%d")
660                 export BUILD_ARGS="-v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY"
661               else
662                 export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d")
663                 export BUILD_ARGS="-r $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY --iso"
664               fi
665             else
666               export OPNFV_ARTIFACT_VERSION=${ARTIFACT_VERSION}
667               if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
668                 export BUILD_ARGS="-v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY"
669               else
670                 export BUILD_ARGS="-r $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY --iso"
671               fi
672             fi
673             # clean for stable but doesn't matter for master
674             if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
675               sudo opnfv-clean
676             fi
677             # start the build
678             cd $WORKSPACE/ci
679             ./build.sh $BUILD_ARGS
680             RPM_VERSION=$(grep Version $BUILD_DIRECTORY/../build/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
681             # list the contents of BUILD_OUTPUT directory
682             ls -al $BUILD_DIRECTORY
683             # save information regarding artifact into file
684             (
685                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
686                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
687                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
688                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
689                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
690                 echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
691                 echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
692                 echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
693                 echo "OPNFV_BUILD_URL=$BUILD_URL"
694             ) > $WORKSPACE/opnfv.properties
695             echo "--------------------------------------------------------"
696             echo "Done!"
697
698 - builder:
699     name: 'apex-workspace-cleanup'
700     builders:
701         - shell: |
702             #!/bin/bash
703             set -o errexit
704             set -o nounset
705             set -o pipefail
706
707             # delete everything that is in $WORKSPACE
708             /bin/rm -rf $WORKSPACE
709
710 - builder:
711     name: 'apex-upload-artifact'
712     builders:
713         - shell: |
714             #!/bin/bash
715             set -o errexit
716             set -o nounset
717             set -o pipefail
718
719             # log info to console
720             echo "Uploading the Apex artifact. This could take some time..."
721             echo "--------------------------------------------------------"
722             echo
723
724             # source the opnfv.properties to get ARTIFACT_VERSION
725             source $WORKSPACE/opnfv.properties
726
727             # upload artifact and additional files to google storage
728             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
729             RPM_INSTALL_PATH=$BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL)
730             RPM_LIST=$RPM_INSTALL_PATH
731             for pkg in common undercloud opendaylight-sfc; do
732                 RPM_LIST+=" ${RPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
733             done
734             SRPM_INSTALL_PATH=$BUILD_DIRECTORY/$(basename $OPNFV_SRPM_URL)
735             SRPM_LIST=$SRPM_INSTALL_PATH
736             for pkg in common undercloud opendaylight-sfc; do
737                 SRPM_LIST+=" ${SRPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
738             done
739             for artifact in $RPM_LIST $SRPM_LIST; do
740               gsutil cp $artifact gs://$GS_URL/$(basename $artifact) > gsutil.iso.log 2>&1
741             done
742             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
743             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
744
745             echo
746             echo "--------------------------------------------------------"
747             echo "Done!"
748             echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
749             echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
750
751 - builder:
752     name: 'apex-deploy-virtual'
753     builders:
754         - shell: |
755             #!/bin/bash
756             set -o errexit
757             set -o nounset
758             set -o pipefail
759
760             # log info to console
761             echo "Starting the Apex virtual deployment."
762             echo "--------------------------------------------------------"
763             echo
764
765             if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
766                 cd $WORKSPACE/../${BUILD_DIRECTORY/build_output/}
767                 WORKSPACE=$(pwd)
768                 echo "WORKSPACE modified to $WORKSPACE"
769                 cd $WORKSPACE/ci
770             elif [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
771                 # if artifact name is passed the pull a
772                 # specific artifact from artifacts.opnfv.org
773                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
774             else
775                 if [[ $BUILD_DIRECTORY == *verify* ]]; then
776                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
777                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
778                 elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
779                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
780                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
781                 fi
782
783                 if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
784                     # if opnfv.properties exists then use the
785                     # local build. Source the file so we get local OPNFV vars
786                     source ${BUILD_DIRECTORY}/../opnfv.properties
787                     RPM_INSTALL_PATH=${BUILD_DIRECTORY}/$(basename $OPNFV_RPM_URL)
788                 else
789                     if [[ $BUILD_DIRECTORY == *verify* ]]; then
790                       echo "BUILD_DIRECTORY is from a verify job, so will not use latest from URL"
791                       echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
792                       exit 1
793                     elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
794                       echo "BUILD_DIRECTORY is from a daily job, so will not use latest from URL"
795                       echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
796                       exit 1
797                     fi
798                     # no opnfv.properties means use the latest from artifacts.opnfv.org
799                     # get the latest.properties to get the link to the latest artifact
800                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
801                     [[ -f opnfv.properties ]] || exit 1
802                     # source the file so we get OPNFV vars
803                     source opnfv.properties
804                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
805                 fi
806             fi
807
808             if [ -z "$DEPLOY_SCENARIO" ]; then
809               echo "Deploy scenario not set!"
810               exit 1
811             fi
812
813             # use local build for verify
814             if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
815                 if [ ! -e "${WORKSPACE}/build/lib" ]; then ln -s ${WORKSPACE}/lib ${WORKSPACE}/build/lib; fi
816                 DEPLOY_CMD="./deploy.sh -c ${WORKSPACE}/build -r ${WORKSPACE}/build/images/"
817                 DEPLOY_FILE="${WORKSPACE}/config/deploy/${DEPLOY_SCENARIO}.yaml"
818                 NETWORK_FILE="${WORKSPACE}/config/network/network_settings.yaml"
819             else
820                 RPM_LIST=$RPM_INSTALL_PATH
821                 for pkg in common undercloud opendaylight-sfc; do
822                     RPM_LIST+=" ${RPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
823                 done
824
825                 # update / install the new rpm
826                 if rpm -q opnfv-apex > /dev/null; then
827                    if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
828                      echo "RPM is already installed"
829                    elif sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
830                        if ! sudo yum downgrade -y $RPM_LIST; then
831                          sudo yum remove -y opnfv-undercloud opnfv-common
832                          sudo yum downgrade -y $RPM_INSTALL_PATH
833                        fi
834                    fi
835                 else
836                    sudo yum install -y $RPM_LIST;
837                 fi
838                 DEPLOY_CMD=opnfv-deploy
839                 DEPLOY_FILE="/etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
840                 NETWORK_FILE="/etc/opnfv-apex/network_settings.yaml"
841             fi
842
843             if [ "$OPNFV_CLEAN" == 'yes' ]; then
844                 if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
845                     sudo ./clean.sh
846                 else
847                     sudo opnfv-clean
848                 fi
849             fi
850             # initiate virtual deployment
851             echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
852             if [ -e $DEPLOY_FILE ]; then
853               sudo $DEPLOY_CMD -v -d ${DEPLOY_FILE} -n $NETWORK_FILE --debug
854             else
855               echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
856               exit 1
857             fi
858             echo
859             echo "--------------------------------------------------------"
860             echo "Done!"
861
862 - builder:
863     name: 'apex-deploy-baremetal'
864     builders:
865         - shell: |
866             #!/bin/bash
867             set -o errexit
868             set -o nounset
869             set -o pipefail
870
871             # log info to console
872             echo "Starting the Apex baremetal deployment."
873             echo "--------------------------------------------------------"
874             echo
875
876             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
877                 # if artifact name is passed the pull a
878                 # specific artifact from artifacts.opnfv.org
879                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
880             else
881                 if [[ $BUILD_DIRECTORY == *apex-build* ]]; then
882                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
883                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
884                 fi
885                 if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
886                     # if opnfv.properties exists then use the
887                     # local build. Source the file so we get local OPNFV vars
888                     source ${BUILD_DIRECTORY}/../opnfv.properties
889                     RPM_INSTALL_PATH=${BUILD_DIRECTORY}/$(basename $OPNFV_RPM_URL)
890                 else
891                     # no opnfv.properties means use the latest from artifacts.opnfv.org
892                     # get the latest.properties to get the link to the latest artifact
893                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
894                     [[ -f opnfv.properties ]] || exit 1
895                     # source the file so we get OPNFV vars
896                     source opnfv.properties
897                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
898                 fi
899             fi
900
901             if [ ! -e "$RPM_INSTALL_PATH" ]; then
902                RPM_INSTALL_PATH=http://${OPNFV_RPM_URL}
903             fi
904
905             RPM_LIST=$RPM_INSTALL_PATH
906             for pkg in common undercloud; do
907                 RPM_LIST+=" ${RPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
908             done
909
910             # update / install the new rpm
911             if rpm -q opnfv-apex > /dev/null; then
912                if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
913                  echo "RPM is already installed"
914                elif sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
915                    if ! sudo yum downgrade -y $RPM_LIST; then
916                      sudo yum remove -y opnfv-undercloud opnfv-common
917                      sudo yum downgrade -y $RPM_INSTALL_PATH
918                    fi
919                fi
920             else
921                sudo yum install -y $RPM_LIST;
922             fi
923
924             # cleanup environment before we start
925             sudo opnfv-clean
926             # initiate baremetal deployment
927             if [ -e /etc/opnfv-apex/network_settings.yaml ]; then
928               if [ -n "$DEPLOY_SCENARIO" ]; then
929                 echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
930                 if [ -e /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml ]; then
931                   sudo opnfv-deploy -i  /root/inventory/pod_settings.yaml \
932                   -d /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml \
933                   -n /root/network/network_settings.yaml --debug
934                 else
935                   echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
936                   exit 1
937                 fi
938               else
939                 echo "Deploy scenario not set!"
940                 exit 1
941               fi
942             else
943               echo "File /etc/opnfv-apex/network_settings.yaml does not exist!"
944               exit 1
945             fi
946
947             echo
948             echo "--------------------------------------------------------"
949             echo "Done!"
950
951 #######################
952 # trigger macros
953 ########################
954 - trigger:
955     name: 'apex-master'
956     triggers:
957         - timed: '0 3 * * *'
958 - trigger:
959     name: 'apex-brahmaputra'
960     triggers:
961         - timed: '0 3 * * *'