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