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