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