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