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