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