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