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