Merge "Add fuel deployment daily jenkins job on zte-pod1."
[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-{verify-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: '{daily-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             same-node: true
354             block: true
355         - 'apex-upload-artifact'
356
357 - job-template:
358     name: 'apex-deploy-virtual-{scenario}-{stream}'
359
360     # Job template for virtual deployment
361     #
362     # Required Variables:
363     #     stream:    branch with - in place of / (eg. stable)
364     #     branch:    branch (eg. stable)
365     node: '{slave}'
366
367     disabled: false
368
369     scm:
370         - git-scm:
371             credentials-id: '{ssh-credentials}'
372             refspec: ''
373             branch: '{branch}'
374
375     parameters:
376         - project-parameter:
377             project: '{project}'
378         - apex-parameter:
379             gs-pathname: '{gs-pathname}'
380         - string:
381             name: DEPLOY_SCENARIO
382             default: '{scenario}'
383             description: "Scenario to deploy with."
384         - string:
385             name: OPNFV_CLEAN
386             default: 'no'
387             description: "Use yes in lower case to invoke clean. Indicates if the deploy environment should be cleaned before deployment"
388
389     properties:
390         - build-blocker:
391             use-build-blocker: true
392             blocking-jobs:
393                 - 'apex-deploy.*{stream}'
394
395     builders:
396         - 'apex-deploy-virtual'
397         - 'apex-workspace-cleanup'
398
399 - job-template:
400     name: 'apex-deploy-baremetal-{scenario}-{stream}'
401
402     # Job template for baremetal deployment
403     #
404     # Required Variables:
405     #     stream:    branch with - in place of / (eg. stable)
406     #     branch:    branch (eg. stable)
407     node: '{slave}'
408
409     disabled: false
410
411     scm:
412         - git-scm:
413             credentials-id: '{ssh-credentials}'
414             refspec: ''
415             branch: '{branch}'
416
417     parameters:
418         - project-parameter:
419             project: '{project}'
420         - apex-parameter:
421             gs-pathname: '{gs-pathname}'
422         - string:
423             name: DEPLOY_SCENARIO
424             default: '{scenario}'
425             description: "Scenario to deploy with."
426
427     properties:
428         - build-blocker:
429             use-build-blocker: true
430             blocking-jobs:
431                 - 'apex-verify.*{stream}'
432                 - 'apex-deploy.*{stream}'
433                 - 'apex-build.*{stream}'
434
435
436     builders:
437         - 'apex-deploy-baremetal'
438         - 'apex-workspace-cleanup'
439
440 # Brahmaputra Daily
441 - job-template:
442     name: 'apex-daily-{stream2}'
443
444     # Job template for daily build
445     #
446     # Required Variables:
447     #     stream:    branch with - in place of / (eg. stable)
448     #     branch:    branch (eg. stable)
449     node: '{slave}'
450
451     disabled: true
452
453     scm:
454         - git-scm:
455             credentials-id: '{ssh-credentials}'
456             refspec: ''
457             branch: '{branch}'
458
459     parameters:
460         - project-parameter:
461             project: '{project}'
462         - apex-parameter:
463             gs-pathname: '{gs-pathname}'
464
465     properties:
466         - build-blocker:
467             use-build-blocker: true
468             blocking-jobs:
469                 - 'apex-verify.*{stream2}'
470                 - 'apex-deploy.*{stream2}'
471                 - 'apex-build.*{stream2}'
472                 - 'apex-runner.*{stream2}'
473
474     triggers:
475         - 'apex-{stream2}'
476
477     builders:
478         - trigger-builds:
479           - project: 'apex-build-{stream2}'
480             git-revision: true
481             current-parameters: true
482             block: true
483         - trigger-builds:
484           - project: 'apex-deploy-baremetal-os-odl_l2-nofeature-ha-{stream2}'
485             predefined-parameters: |
486               BUILD_DIRECTORY=apex-build-{stream2}/build_output
487               OPNFV_CLEAN=yes
488             git-revision: true
489             block: true
490         - trigger-builds:
491           - project: 'functest-apex-{slave}-daily-{stream2}'
492             predefined-parameters:
493               DEPLOY_SCENARIO=os-odl_l2-nofeature-ha
494             block: true
495             block-thresholds:
496                 build-step-failure-threshold: 'never'
497                 failure-threshold: 'never'
498                 unstable-threshold: 'FAILURE'
499         - trigger-builds:
500           - project: 'yardstick-apex-{slave}-daily-{stream2}'
501             predefined-parameters:
502               DEPLOY_SCENARIO=os-odl_l2-nofeature-ha
503             block: true
504             block-thresholds:
505                 build-step-failure-threshold: 'never'
506                 failure-threshold: 'never'
507                 unstable-threshold: 'FAILURE'
508         - trigger-builds:
509           - project: 'apex-deploy-baremetal-os-onos-nofeature-ha-{stream2}'
510             predefined-parameters:
511               BUILD_DIRECTORY=apex-build-{stream2}/build_output
512             git-revision: true
513             block: true
514         - trigger-builds:
515           - project: 'functest-apex-{slave}-daily-{stream2}'
516             predefined-parameters:
517               DEPLOY_SCENARIO=os-onos-nofeature-ha
518             block: true
519             block-thresholds:
520                 build-step-failure-threshold: 'never'
521                 failure-threshold: 'never'
522                 unstable-threshold: 'FAILURE'
523         - trigger-builds:
524           - project: 'yardstick-apex-{slave}-daily-{stream2}'
525             predefined-parameters:
526               DEPLOY_SCENARIO=os-onos-nofeature-ha
527             block: true
528             block-thresholds:
529                 build-step-failure-threshold: 'never'
530                 failure-threshold: 'never'
531                 unstable-threshold: 'FAILURE'
532         - trigger-builds:
533           - project: 'apex-deploy-baremetal-os-odl_l3-nofeature-ha-{stream2}'
534             predefined-parameters:
535               BUILD_DIRECTORY=apex-build-{stream2}/build_output
536             git-revision: true
537             block: true
538         - trigger-builds:
539           - project: 'functest-apex-{slave}-daily-{stream2}'
540             predefined-parameters:
541               DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
542             block: true
543             block-thresholds:
544                 build-step-failure-threshold: 'never'
545                 failure-threshold: 'never'
546                 unstable-threshold: 'FAILURE'
547         - trigger-builds:
548           - project: 'yardstick-apex-{slave}-daily-{stream2}'
549             predefined-parameters:
550               DEPLOY_SCENARIO=os-odl_l3-nofeature-ha
551             block: true
552             block-thresholds:
553                 build-step-failure-threshold: 'never'
554                 failure-threshold: 'never'
555                 unstable-threshold: 'FAILURE'
556         - trigger-builds:
557           - project: 'apex-deploy-baremetal-os-odl_l2-bgpvpn-ha-{stream2}'
558             predefined-parameters:
559               BUILD_DIRECTORY=apex-build-{stream2}/build_output
560             git-revision: true
561             block: true
562         - trigger-builds:
563           - project: 'functest-apex-{slave}-daily-{stream2}'
564             predefined-parameters:
565               DEPLOY_SCENARIO=os-odl_l2-bgpvpn-ha
566             block: true
567             block-thresholds:
568                 build-step-failure-threshold: 'never'
569                 failure-threshold: 'never'
570                 unstable-threshold: 'FAILURE'
571         - trigger-builds:
572           - project: 'yardstick-apex-{slave}-daily-{stream2}'
573             predefined-parameters:
574               DEPLOY_SCENARIO=os-odl_l2-bgpvpn-ha
575             block: true
576             block-thresholds:
577                 build-step-failure-threshold: 'never'
578                 failure-threshold: 'never'
579                 unstable-threshold: 'FAILURE'
580
581 # Master Daily
582 - job-template:
583     name: 'apex-daily-{stream1}'
584
585     # Job template for daily build
586     #
587     # Required Variables:
588     #     stream:    branch with - in place of / (eg. stable)
589     #     branch:    branch (eg. stable)
590     node: '{daily-slave}'
591
592     disabled: false
593
594     scm:
595         - git-scm:
596             credentials-id: '{ssh-credentials}'
597             refspec: ''
598             branch: '{branch}'
599
600     parameters:
601         - project-parameter:
602             project: '{project}'
603         - apex-parameter:
604             gs-pathname: '{gs-pathname}'
605
606     properties:
607         - build-blocker:
608             use-build-blocker: true
609             blocking-jobs:
610                 - 'apex-verify.*{stream1}'
611                 - 'apex-deploy.*{stream1}'
612                 - 'apex-build.*{stream1}'
613                 - 'apex-runner.*{stream1}'
614
615     triggers:
616         - 'apex-{stream1}'
617
618     builders:
619         - trigger-builds:
620           - project: 'apex-build-{stream1}'
621             git-revision: true
622             current-parameters: true
623             same-node: true
624             block: true
625         - trigger-builds:
626           - project: 'apex-deploy-virtual-nosdn-nofeature-ha-{stream1}'
627             predefined-parameters: |
628               BUILD_DIRECTORY=apex-build-{stream1}/build
629               OPNFV_CLEAN=yes
630             git-revision: true
631             same-node: true
632             block: true
633         - trigger-builds:
634           - project: 'functest-apex-{slave}-daily-{stream1}'
635             predefined-parameters:
636               DEPLOY_SCENARIO=os-nosdn-nofeature-ha
637             block: true
638             same-node: true
639             block-thresholds:
640                 build-step-failure-threshold: 'never'
641                 failure-threshold: 'never'
642                 unstable-threshold: 'FAILURE'
643         - trigger-builds:
644           - project: 'yardstick-apex-{slave}-daily-{stream1}'
645             predefined-parameters:
646               DEPLOY_SCENARIO=os-nosdn-nofeature-ha
647             block: true
648             same-node: true
649             block-thresholds:
650                 build-step-failure-threshold: 'never'
651                 failure-threshold: 'never'
652                 unstable-threshold: 'FAILURE'
653
654 - job-template:
655     name: 'apex-gs-clean-{stream}'
656
657     # Job template for clean
658     #
659     # Required Variables:
660     #     stream:    branch with - in place of / (eg. stable)
661     node: '{slave}'
662
663     disabled: false
664
665     parameters:
666         - project-parameter:
667             project: '{project}'
668         - apex-parameter:
669             gs-pathname: '{gs-pathname}'
670
671     builders:
672         - 'apex-gs-clean'
673
674     triggers:
675         - 'apex-gs-clean-{stream}'
676
677
678 ########################
679 # parameter macros
680 ########################
681 - parameter:
682     name: apex-parameter
683     parameters:
684         - string:
685             name: ARTIFACT_NAME
686             default: 'latest'
687             description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
688         - string:
689             name: ARTIFACT_VERSION
690             default: 'daily'
691             description: "Artifact version type"
692         - string:
693             name: BUILD_DIRECTORY
694             default: $WORKSPACE/build
695             description: "Directory where the build artifact will be located upon the completion of the build."
696         - string:
697             name: CACHE_DIRECTORY
698             default: $HOME/opnfv/cache{gs-pathname}
699             description: "Directory where the cache to be used during the build is located."
700         - string:
701             name: GIT_BASE
702             default: https://gerrit.opnfv.org/gerrit/$PROJECT
703             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
704         - string:
705             name: GS_URL
706             default: artifacts.opnfv.org/$PROJECT{gs-pathname}
707             description: "URL to Google Storage."
708
709 ########################
710 # builder macros
711 ########################
712 - builder:
713     name: 'apex-build'
714     builders:
715         - shell: |
716             #!/bin/bash
717             set -o errexit
718             set -o nounset
719             set -o pipefail
720             # log info to console
721             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
722             echo "---------------------------------------------------------------------------------------"
723             echo
724             # create the cache directory if it doesn't exist
725             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
726             # set OPNFV_ARTIFACT_VERSION
727             if echo $BUILD_TAG | grep "apex-verify" 1> /dev/null; then
728               if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
729                 export OPNFV_ARTIFACT_VERSION=brahmaputra-dev${BUILD_NUMBER}
730                 export BUILD_ARGS="-v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY"
731               else
732                 export OPNFV_ARTIFACT_VERSION=dev${BUILD_NUMBER}
733                 export BUILD_ARGS="-r $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY"
734               fi
735             elif [ "$ARTIFACT_VERSION" == "daily" ]; then
736               if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
737                 export OPNFV_ARTIFACT_VERSION=brahmaputra-$(date -u +"%Y-%m-%d")
738                 export BUILD_ARGS="-v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY"
739               else
740                 export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d")
741                 export BUILD_ARGS="-r $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY --iso"
742               fi
743             else
744               export OPNFV_ARTIFACT_VERSION=${ARTIFACT_VERSION}
745               if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
746                 export BUILD_ARGS="-v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY"
747               else
748                 export BUILD_ARGS="-r $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY --iso"
749               fi
750             fi
751             # clean for stable but doesn't matter for master
752             if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
753               sudo opnfv-clean
754             fi
755             # start the build
756             cd $WORKSPACE/ci
757             ./build.sh $BUILD_ARGS
758             RPM_VERSION=$(grep Version: $BUILD_DIRECTORY/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
759             # list the contents of BUILD_OUTPUT directory
760             ls -al $BUILD_DIRECTORY
761             # save information regarding artifact into file
762             (
763                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
764                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
765                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
766                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
767                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/release/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
768                 echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
769                 echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
770                 echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/noarch/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
771                 echo "OPNFV_BUILD_URL=$BUILD_URL"
772             ) > $WORKSPACE/opnfv.properties
773             echo "--------------------------------------------------------"
774             echo "Done!"
775
776 - builder:
777     name: 'apex-workspace-cleanup'
778     builders:
779         - shell: |
780             #!/bin/bash
781             set -o errexit
782             set -o nounset
783             set -o pipefail
784
785             # delete everything that is in $WORKSPACE
786             sudo /bin/rm -rf $WORKSPACE
787
788 - builder:
789     name: 'apex-upload-artifact'
790     builders:
791         - shell: |
792             #!/bin/bash
793             set -o errexit
794             set -o nounset
795             set -o pipefail
796
797             # log info to console
798             echo "Uploading the Apex artifact. This could take some time..."
799             echo "--------------------------------------------------------"
800             echo
801
802             # source the opnfv.properties to get ARTIFACT_VERSION
803             source $WORKSPACE/opnfv.properties
804
805             # upload artifact and additional files to google storage
806             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
807             RPM_INSTALL_PATH=$BUILD_DIRECTORY/noarch
808             RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
809             VERSION_EXTENSION=$(echo $(basename $OPNFV_RPM_URL) | sed 's/opnfv-apex-//')
810             for pkg in common undercloud opendaylight-sfc onos; do
811                 RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}"
812             done
813             SRPM_INSTALL_PATH=$BUILD_DIRECTORY
814             SRPM_LIST=$SRPM_INSTALL_PATH/$(basename $OPNFV_SRPM_URL)
815             for pkg in common undercloud opendaylight-sfc onos; do
816                 SRPM_LIST+=" ${SRPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}"
817             done
818             for artifact in $RPM_LIST $SRPM_LIST; do
819               gsutil cp $artifact gs://$GS_URL/$(basename $artifact) > gsutil.iso.log 2>&1
820             done
821             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
822             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
823
824             echo
825             echo "--------------------------------------------------------"
826             echo "Done!"
827             echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
828             echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
829
830 - builder:
831     name: 'apex-gs-cleanup'
832     builders:
833         - shell: |
834             #!/bin/bash
835             set -o errexit
836             set -o nounset
837             set -o pipefail
838
839             # log info to console
840             echo "Cleaning Google Storage"
841             echo "-----------------------"
842             echo
843
844             thirty_days_ago=$(date -d "30 days ago" +"%Y%m%d")
845
846             for i in $(gsutil ls gs://$GS_URL/*201?*); do
847                 filedate=$(date -d "$(echo $i | grep -Eo 201[0-9]-?[0-9][0-9]-?[0-9][0-9])" +"%Y%m%d")
848                 if [ $filedate -lt $thirty_days_ago ]; then
849                   # gsutil indicates what it is removing so no need for output here
850                   gsutil rm $i
851                 fi
852             done
853
854 - builder:
855     name: 'apex-deploy-virtual'
856     builders:
857         - shell: |
858             #!/bin/bash
859             set -o errexit
860             set -o nounset
861             set -o pipefail
862
863             # log info to console
864             echo "Starting the Apex virtual deployment."
865             echo "--------------------------------------------------------"
866             echo
867
868             if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
869                 cd $WORKSPACE/../${BUILD_DIRECTORY/build_output/}
870                 WORKSPACE=$(pwd)
871                 echo "WORKSPACE modified to $WORKSPACE"
872                 cd $WORKSPACE/ci
873             elif [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
874                 # if artifact name is passed the pull a
875                 # specific artifact from artifacts.opnfv.org
876                 RPM_INSTALL_PATH=$GS_URL
877                 RPM_LIST=$RPM_INSTALL_PATH/$ARTIFACT_NAME
878             else
879                 if [[ $BUILD_DIRECTORY == *verify* ]]; then
880                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
881                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
882                 elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
883                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
884                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
885                 fi
886
887                 if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
888                     # if opnfv.properties exists then use the
889                     # local build. Source the file so we get local OPNFV vars
890                     source ${BUILD_DIRECTORY}/../opnfv.properties
891                     RPM_INSTALL_PATH=${BUILD_DIRECTORY}/noarch
892                     RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
893                 else
894                     if [[ $BUILD_DIRECTORY == *verify* ]]; then
895                       echo "BUILD_DIRECTORY is from a verify job, so will not use latest from URL"
896                       echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
897                       exit 1
898                     elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
899                       echo "BUILD_DIRECTORY is from a daily job, so will not use latest from URL"
900                       echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
901                       exit 1
902                     fi
903                     # no opnfv.properties means use the latest from artifacts.opnfv.org
904                     # get the latest.properties to get the link to the latest artifact
905                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
906                     [[ -f opnfv.properties ]] || exit 1
907                     # source the file so we get OPNFV vars
908                     source opnfv.properties
909                     RPM_INSTALL_PATH=$(echo $OPNFV_RPM_URL | sed 's/'"$(basename $OPNFV_RPM_URL)"'//')
910                     RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
911                 fi
912             fi
913
914             if [ -z "$DEPLOY_SCENARIO" ]; then
915               echo "Deploy scenario not set!"
916               exit 1
917             fi
918
919             # use local build for verify
920             if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
921                 if [ ! -e "${WORKSPACE}/build/lib" ]; then ln -s ${WORKSPACE}/lib ${WORKSPACE}/build/lib; fi
922                 DEPLOY_CMD="CONFIG=${WORKSPACE}/build RESOURCES=${WORKSPACE}/build/images/ ./deploy.sh -c ${WORKSPACE}/build -r ${WORKSPACE}/build/images/"
923                 DEPLOY_FILE="${WORKSPACE}/config/deploy/${DEPLOY_SCENARIO}.yaml"
924                 NETWORK_FILE="${WORKSPACE}/config/network/network_settings.yaml"
925                 # Make sure python34 is installed
926                 if ! rpm -q python34 > /dev/null; then
927                     sudo yum install -y epel-release
928                     if ! sudo yum install -y python34; then
929                         echo "Failed to install python34"
930                         exit 1
931                     fi
932                 fi
933                 if ! rpm -q python34-PyYAML > /dev/null; then
934                     sudo yum install -y epel-release
935                     if ! sudo yum install -y python34-PyYAML; then
936                         echo "Failed to install python34-PyYAML"
937                         exit 1
938                     fi
939                 fi
940                 if ! rpm -q python34-setuptools > /dev/null; then
941                     if ! sudo yum install -y python34-setuptools; then
942                         echo "Failed to install python34-setuptools"
943                         exit 1
944                     fi
945                 fi
946                 if [ -z ${PYTHONPATH:-} ]; then
947                     export PYTHONPATH=${WORKSPACE}/lib/python
948                 else
949                     export PYTHONPATH=$PYTHONPATH:${WORKSPACE}/lib/python
950                 fi
951             else
952                 VERSION_EXTENSION=$(echo $(basename $RPM_LIST) | sed 's/opnfv-apex-//')
953                 for pkg in common undercloud opendaylight-sfc onos; do
954                     RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}"
955                 done
956
957                 # update / install the new rpm
958                 if rpm -q opnfv-apex > /dev/null; then
959                    INSTALLED_RPMS=$(rpm -qa | grep apex)
960                    for x in $INSTALLED_RPMS; do
961                      INSTALLED_RPM_VER=$(echo $x | sed 's/opnfv-apex-//').rpm
962                      # Does each RPM's version match the version required for deployment
963                      if [ "$INSTALLED_RPM_VER" == "$VERSION_EXTENSION" ]; then
964                        echo "RPM $x is already installed"
965                      else
966                        echo "RPM $x does not match $VERSION_EXTENSION"
967                        echo "Will upgrade/downgrade RPMs..."
968                        # Try to upgrade/downgrade RPMS
969                        if sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
970                          if ! sudo yum downgrade -y $RPM_LIST; then
971                            sudo yum remove -y opnfv-apex-undercloud opnfv-apex-common opnfv-apex-opendaylight-sfc opnfv-apex-onos
972                            sudo yum downgrade -y $RPM_INSTALL_PATH
973                          fi
974                        fi
975                        break
976                      fi
977                    done
978                 else
979                    sudo yum install -y $RPM_LIST;
980                 fi
981                 DEPLOY_CMD=opnfv-deploy
982                 DEPLOY_FILE="/etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
983                 NETWORK_FILE="/etc/opnfv-apex/network_settings.yaml"
984                 export RESOURCES="/var/opt/opnfv/images"
985                 export CONFIG="/var/opt/opnfv"
986             fi
987
988             if [ "$OPNFV_CLEAN" == 'yes' ]; then
989                 if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
990                     sudo CONFIG=../lib ./clean.sh
991                 else
992                     sudo opnfv-clean
993                 fi
994             fi
995             # initiate virtual deployment
996             echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
997             if [ -e $DEPLOY_FILE ]; then
998               sudo $DEPLOY_CMD -v -d ${DEPLOY_FILE} -n $NETWORK_FILE --debug
999             else
1000               echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
1001               exit 1
1002             fi
1003             echo
1004             echo "--------------------------------------------------------"
1005             echo "Done!"
1006
1007 - builder:
1008     name: 'apex-deploy-baremetal'
1009     builders:
1010         - shell: |
1011             #!/bin/bash
1012             set -o errexit
1013             set -o nounset
1014             set -o pipefail
1015
1016             # log info to console
1017             echo "Starting the Apex baremetal deployment."
1018             echo "--------------------------------------------------------"
1019             echo
1020
1021             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
1022                 # if artifact name is passed the pull a
1023                 # specific artifact from artifacts.opnfv.org
1024                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
1025             else
1026                 if [[ $BUILD_DIRECTORY == *apex-build* ]]; then
1027                   BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
1028                   echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
1029                 fi
1030                 if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
1031                     # if opnfv.properties exists then use the
1032                     # local build. Source the file so we get local OPNFV vars
1033                     source ${BUILD_DIRECTORY}/../opnfv.properties
1034                     RPM_INSTALL_PATH=${BUILD_DIRECTORY}/$(basename $OPNFV_RPM_URL)
1035                 else
1036                     # no opnfv.properties means use the latest from artifacts.opnfv.org
1037                     # get the latest.properties to get the link to the latest artifact
1038                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
1039                     [[ -f opnfv.properties ]] || exit 1
1040                     # source the file so we get OPNFV vars
1041                     source opnfv.properties
1042                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
1043                 fi
1044             fi
1045
1046             if [ ! -e "$RPM_INSTALL_PATH" ]; then
1047                RPM_INSTALL_PATH=http://${OPNFV_RPM_URL}
1048             fi
1049
1050             RPM_LIST=$RPM_INSTALL_PATH
1051             for pkg in common undercloud; do
1052                 RPM_LIST+=" ${RPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
1053             done
1054
1055             # update / install the new rpm
1056             if rpm -q opnfv-apex > /dev/null; then
1057                if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
1058                  echo "RPM is already installed"
1059                elif sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
1060                    if ! sudo yum downgrade -y $RPM_LIST; then
1061                      sudo yum remove -y opnfv-undercloud opnfv-common
1062                      sudo yum downgrade -y $RPM_INSTALL_PATH
1063                    fi
1064                fi
1065             else
1066                sudo yum install -y $RPM_LIST;
1067             fi
1068
1069             # cleanup environment before we start
1070             sudo opnfv-clean
1071             # initiate baremetal deployment
1072             if [ -e /etc/opnfv-apex/network_settings.yaml ]; then
1073               if [ -n "$DEPLOY_SCENARIO" ]; then
1074                 echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
1075                 if [ -e /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml ]; then
1076                   sudo opnfv-deploy -i  /root/inventory/pod_settings.yaml \
1077                   -d /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml \
1078                   -n /root/network/network_settings.yaml --debug
1079                 else
1080                   echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
1081                   exit 1
1082                 fi
1083               else
1084                 echo "Deploy scenario not set!"
1085                 exit 1
1086               fi
1087             else
1088               echo "File /etc/opnfv-apex/network_settings.yaml does not exist!"
1089               exit 1
1090             fi
1091
1092             echo
1093             echo "--------------------------------------------------------"
1094             echo "Done!"
1095
1096 #######################
1097 # trigger macros
1098 ########################
1099 - trigger:
1100     name: 'apex-master'
1101     triggers:
1102         - timed: '0 3 * * *'
1103 - trigger:
1104     name: 'apex-brahmaputra'
1105     triggers:
1106         - timed: '0 3 * * *'
1107 - trigger:
1108     name: 'apex-gs-clean-{stream}'
1109     triggers:
1110         - timed: '0 2 * * *'