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