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