apex: adds brahmaputra and moves daily to use baremetal
[releng.git] / jjb / apex / apex.yml
1 - project:
2     name: apex
3     jobs:
4         - 'apex-verify-{stream}'
5         - 'apex-merge-{stream}'
6         - 'apex-build-{stream}'
7         - 'apex-deploy-virtual-{stream}'
8         - 'apex-deploy-baremetal-{stream}'
9         - 'apex-daily-{stream}'
10
11     # stream:    branch with - in place of / (eg. stable-arno)
12     # branch:    branch (eg. stable/arno)
13     stream:
14         - master:
15             branch: 'master'
16             gs-pathname: ''
17         - brahmaputra:
18             branch: 'stable/brahmaputra'
19             gs-pathname: '/brahmaputra'
20
21     project: 'apex'
22
23 - job-template:
24     name: 'apex-verify-{stream}'
25
26     node: opnfv-jump-1
27
28     parameters:
29         - apex-parameter:
30             gs-pathname: '{gs-pathname}'
31         - project-parameter:
32             project: '{project}'
33         - gerrit-parameter:
34             branch: '{branch}'
35         - string:
36             name: GIT_BASE
37             default: https://gerrit.opnfv.org/gerrit/$PROJECT
38             description: "Used for overriding the GIT URL coming from parameters macro."
39         - string:
40             name: ARTIFACT_VERSION
41             default: 'dev'
42             description: "Artifact version type"
43
44     scm:
45         - gerrit-trigger-scm:
46             credentials-id: '{ssh-credentials}'
47             refspec: '$GERRIT_REFSPEC'
48             choosing-strategy: 'gerrit'
49
50     triggers:
51         - gerrit:
52             trigger-on:
53                 - patchset-created-event:
54                     exclude-drafts: 'false'
55                     exclude-trivial-rebase: 'false'
56                     exclude-no-code-change: 'false'
57                 - draft-published-event
58                 - comment-added-contains-event:
59                     comment-contains-value: 'recheck'
60                 - comment-added-contains-event:
61                     comment-contains-value: 'reverify'
62             projects:
63               - project-compare-type: 'ANT'
64                 project-pattern: 'apex'
65                 branches:
66                   - branch-compare-type: 'ANT'
67                     branch-pattern: '**/master'
68                 file-paths:
69                   - compare-type: ANT
70                     pattern: 'ci/**'
71                   - compare-type: ANT
72                     pattern: 'build/**'
73                   - compare-type: ANT
74                     pattern: 'lib/**'
75                   - compare-type: ANT
76                     pattern: 'config/**'
77                 forbidden-file-paths:
78                   - compare-type: ANT
79                     pattern: 'docs/**'
80
81     properties:
82         - build-blocker:
83             use-build-blocker: true
84             blocking-jobs:
85                 - "apex-daily.*"
86                 - "apex-deploy.*"
87                 - "apex-build.*"
88
89     builders:
90         - 'apex-build'
91         - 'apex-deploy-virtual'
92         - 'apex-workspace-cleanup'
93
94 - job-template:
95     name: 'apex-merge-{stream}'
96
97     # builder-merge job to run JJB update
98     #
99     # This job's purpose is to update all the JJB
100
101     node: opnfv-jump-1
102
103     disabled: true
104
105     parameters:
106         - apex-parameter:
107             gs-pathname: '{gs-pathname}'
108         - project-parameter:
109             project: '{project}'
110         - gerrit-parameter:
111             branch: '{branch}'
112         - string:
113             name: GIT_BASE
114             default: https://gerrit.opnfv.org/gerrit/$PROJECT
115             description: "Used for overriding the GIT URL coming from parameters macro."
116
117     scm:
118         - gerrit-trigger-scm:
119             credentials-id: '{ssh-credentials}'
120             refspec: ''
121             choosing-strategy: 'default'
122
123     triggers:
124         - gerrit:
125             trigger-on:
126                 - change-merged-event
127                 - comment-added-contains-event:
128                     comment-contains-value: 'remerge'
129             projects:
130               - project-compare-type: 'ANT'
131                 project-pattern: 'apex'
132                 branches:
133                     - branch-compare-type: 'ANT'
134                       branch-pattern: '**/master'
135                 forbidden-file-paths:
136                   - compare-type: ANT
137                     pattern: 'docs/**'
138
139     builders:
140         - 'apex-build'
141         - 'apex-deploy-virtual'
142         - 'apex-workspace-cleanup'
143
144 - job-template:
145     name: 'apex-build-{stream}'
146
147     # Job template for builds
148     #
149     # Required Variables:
150     #     stream:    branch with - in place of / (eg. stable)
151     #     branch:    branch (eg. stable)
152     node: opnfv-jump-1
153
154     disabled: false
155
156     parameters:
157         - project-parameter:
158             project: '{project}'
159         - apex-parameter:
160             gs-pathname: '{gs-pathname}'
161         - gerrit-parameter:
162             branch: '{branch}'
163         - string:
164             name: GIT_BASE
165             default: https://gerrit.opnfv.org/gerrit/$PROJECT
166             description: "Used for overriding the GIT URL coming from parameters macro."
167
168     scm:
169         - git-scm:
170             credentials-id: '{ssh-credentials}'
171             refspec: ''
172             branch: '{branch}'
173
174     properties:
175         - build-blocker:
176             use-build-blocker: true
177             blocking-jobs:
178                 - "apex-deploy.*"
179
180     builders:
181         - 'apex-build'
182         - 'apex-deploy-virtual'
183         - 'apex-upload-artifact'
184         - 'apex-workspace-cleanup'
185
186 - job-template:
187     name: 'apex-deploy-virtual-{stream}'
188
189     # Job template for virtual deployment
190     #
191     # Required Variables:
192     #     stream:    branch with - in place of / (eg. stable)
193     #     branch:    branch (eg. stable)
194     node: opnfv-jump-1
195
196     disabled: false
197
198     scm:
199         - git-scm:
200             credentials-id: '{ssh-credentials}'
201             refspec: ''
202             branch: '{branch}'
203
204     parameters:
205         - project-parameter:
206             project: '{project}'
207         - apex-parameter:
208             gs-pathname: '{gs-pathname}'
209
210     properties:
211         - build-blocker:
212             use-build-blocker: true
213             blocking-jobs:
214                 - "apex-verify.*"
215                 - "apex-deploy.*"
216                 - "apex-build.*"
217
218     builders:
219         - 'apex-deploy-virtual'
220         - 'apex-workspace-cleanup'
221
222 - job-template:
223     name: 'apex-deploy-baremetal-{stream}'
224
225     # Job template for baremetal deployment
226     #
227     # Required Variables:
228     #     stream:    branch with - in place of / (eg. stable)
229     #     branch:    branch (eg. stable)
230     node: opnfv-jump-1
231
232     disabled: false
233
234     scm:
235         - git-scm:
236             credentials-id: '{ssh-credentials}'
237             refspec: ''
238             branch: '{branch}'
239
240     parameters:
241         - project-parameter:
242             project: '{project}'
243         - apex-parameter:
244             gs-pathname: '{gs-pathname}'
245
246     properties:
247         - build-blocker:
248             use-build-blocker: true
249             blocking-jobs:
250                 - "apex-verify.*"
251                 - "apex-deploy.*"
252                 - "apex-build.*"
253                 - "apex-daily.*"
254
255     builders:
256         - 'apex-deploy-baremetal'
257         - 'apex-workspace-cleanup'
258
259 - job-template:
260     name: 'apex-daily-{stream}'
261
262     # Job template for daily build
263     #
264     # Required Variables:
265     #     stream:    branch with - in place of / (eg. stable)
266     #     branch:    branch (eg. stable)
267     node: opnfv-jump-1
268
269     disabled: false
270
271     scm:
272         - git-scm:
273             credentials-id: '{ssh-credentials}'
274             refspec: ''
275             branch: '{branch}'
276
277     parameters:
278         - project-parameter:
279             project: '{project}'
280         - apex-parameter:
281             gs-pathname: '{gs-pathname}'
282
283     properties:
284         - build-blocker:
285             use-build-blocker: true
286             blocking-jobs:
287                 - "apex-verify.*"
288                 - "apex-deploy.*"
289                 - "apex-build.*"
290
291     triggers:
292         - 'apex-master'
293
294     builders:
295         - trigger-builds:
296           - project: 'apex-build-{stream}'
297             git-revision: true
298             block: true
299         - trigger-builds:
300           - project: 'apex-deploy-baremetal-{stream}'
301             git-revision: true
302             block: true
303         - trigger-builds:
304           - project: 'functest-apex-opnfv-jump-1-daily-{stream}'
305             block: true
306             block-thresholds:
307                 build-step-failure-threshold: 'never'
308                 failure-threshold: 'never'
309                 unstable-threshold: 'FAILURE'
310
311 ########################
312 # parameter macros
313 ########################
314 - parameter:
315     name: apex-parameter
316     parameters:
317         - string:
318             name: ARTIFACT_NAME
319             default: 'latest'
320             description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
321         - string:
322             name: ARTIFACT_VERSION
323             default: 'daily'
324             description: "Artifact version type"
325         - string:
326             name: BUILD_DIRECTORY
327             default: $WORKSPACE/build_output
328             description: "Directory where the build artifact will be located upon the completion of the build."
329         - string:
330             name: CACHE_DIRECTORY
331             default: $HOME/opnfv/cache{gs-pathname}
332             description: "Directory where the cache to be used during the build is located."
333         - string:
334             name: GIT_BASE
335             default: https://gerrit.opnfv.org/gerrit/$PROJECT
336             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
337         - string:
338             name: GS_URL
339             default: artifacts.opnfv.org/$PROJECT{gs-pathname}
340             description: "URL to Google Storage."
341
342 ########################
343 # builder macros
344 ########################
345 - builder:
346     name: 'apex-build'
347     builders:
348         - shell: |
349             #!/bin/bash
350             set -o errexit
351             set -o nounset
352             set -o pipefail
353             # log info to console
354             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
355             echo "---------------------------------------------------------------------------------------"
356             echo
357             # create the cache directory if it doesn't exist
358             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
359             # set OPNFV_ARTIFACT_VERSION
360             if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
361               export OPNFV_ARTIFACT_VERSION="bramaputra.1.rc0"
362             else
363               if [ "$ARTIFACT_VERSION" == "dev" ]; then
364                 export OPNFV_ARTIFACT_VERSION=dev${BUILD_NUMBER}
365               elif [ "$ARTIFACT_VERSION" == "daily" ]; then
366                 export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d")
367               else
368                 export OPNFV_ARTIFACT_VERSION=${ARTIFACT_VERSION}
369               fi
370             fi
371             # start the build
372             cd $WORKSPACE/ci
373             ./build.sh -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
374             RPM_VERSION=$(grep Version $BUILD_DIRECTORY/../build/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
375             # list the contents of BUILD_OUTPUT directory
376             ls -al $BUILD_DIRECTORY
377             # save information regarding artifact into file
378             (
379                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
380                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
381                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
382                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
383                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
384                 echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
385                 echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
386                 echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
387                 echo "OPNFV_BUILD_URL=$BUILD_URL"
388             ) > $WORKSPACE/opnfv.properties
389             echo
390             echo "--------------------------------------------------------"
391
392 - builder:
393     name: 'apex-workspace-cleanup'
394     builders:
395         - shell: |
396             #!/bin/bash
397             set -o errexit
398             set -o nounset
399             set -o pipefail
400
401             # delete everything that is in $WORKSPACE
402             /bin/rm -rf $WORKSPACE
403
404 - builder:
405     name: 'apex-upload-artifact'
406     builders:
407         - shell: |
408             #!/bin/bash
409             set -o errexit
410             set -o nounset
411             set -o pipefail
412
413             # log info to console
414             echo "Uploading the Apex artifact. This could take some time..."
415             echo "--------------------------------------------------------"
416             echo
417
418             # source the opnfv.properties to get ARTIFACT_VERSION
419             source $WORKSPACE/opnfv.properties
420
421             # upload artifact and additional files to google storage
422             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
423             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL) gs://$GS_URL/$(basename $OPNFV_RPM_URL) > gsutil.iso.log 2>&1
424             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_SRPM_URL) gs://$GS_URL/$(basename $OPNFV_SRPM_URL) > gsutil.iso.log 2>&1
425             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
426             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
427
428             echo
429             echo "--------------------------------------------------------"
430             echo "Done!"
431             echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
432             echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
433
434 - builder:
435     name: 'apex-deploy-virtual'
436     builders:
437         - shell: |
438             #!/bin/bash
439             set -o errexit
440             set -o nounset
441             set -o pipefail
442
443             # log info to console
444             echo "Starting the Apex virtual deployment."
445             echo "--------------------------------------------------------"
446             echo
447
448             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
449                 # if artifact name is passed the pull a
450                 # specific artifact from artifacts.opnfv.org
451                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
452             else
453                 if [[ -f opnfv.properties ]]; then
454                     # if opnfv.properties exists then use the
455                     # local build. Source the file so we get local OPNFV vars
456                     source opnfv.properties
457                     RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
458                 else
459                     # no opnfv.properties means use the latest from artifacts.opnfv.org
460                     # get the latest.properties to get the link to the latest artifact
461                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
462                     [[ -f opnfv.properties ]] || exit 1
463                     # source the file so we get OPNFV vars
464                     source opnfv.properties
465                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
466                 fi
467             fi
468
469             source opnfv.properties
470             RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
471
472             # update / install the new rpm
473             if rpm -q opnfv-apex > /dev/null; then
474                if sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
475                    sudo yum downgrade -y $RPM_INSTALL_PATH;
476                fi
477             else
478                sudo yum install -y $RPM_INSTALL_PATH;
479             fi
480
481             # cleanup virtual machines before we start
482             sudo opnfv-clean
483             # initiate virtual deployment
484             if [ -e /usr/share/doc/opnfv/network_settings.yaml.example ]; then
485               sudo opnfv-deploy -v -d /usr/share/doc/opnfv/deploy_settings.yaml.example -n /usr/share/doc/opnfv/network_settings.yaml.example
486             else
487               sudo opnfv-deploy -v
488             fi
489             echo
490             echo "--------------------------------------------------------"
491             echo "Done!"
492
493 - builder:
494     name: 'apex-deploy-baremetal'
495     builders:
496         - shell: |
497             #!/bin/bash
498             set -o errexit
499             set -o nounset
500             set -o pipefail
501
502             # log info to console
503             echo "Starting the Apex baremetal deployment."
504             echo "--------------------------------------------------------"
505             echo
506
507             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
508                 # if artifact name is passed the pull a
509                 # specific artifact from artifacts.opnfv.org
510                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
511             else
512                 if [[ -f opnfv.properties ]]; then
513                     # if opnfv.properties exists then use the
514                     # local build. Source the file so we get local OPNFV vars
515                     source opnfv.properties
516                     RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
517                 else
518                     # no opnfv.properties means use the latest from artifacts.opnfv.org
519                     # get the latest.properties to get the link to the latest artifact
520                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
521                     [[ -f opnfv.properties ]] || exit 1
522                     # source the file so we get OPNFV vars
523                     source opnfv.properties
524                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
525                 fi
526             fi
527
528             source opnfv.properties
529             RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
530             if [ ! -e "$RPM_INSTALL_PATH" ]; then
531                RPM_INSTALL_PATH=http://${OPNFV_RPM_URL}
532             fi
533
534             # update / install the new rpm
535             if rpm -q opnfv-apex > /dev/null; then
536                if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
537                  echo "RPM is already installed"
538                elif sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
539                    sudo yum downgrade -y $RPM_INSTALL_PATH;
540                fi
541             else
542                sudo yum install -y $RPM_INSTALL_PATH;
543             fi
544
545             # cleanup environment before we start
546             sudo opnfv-clean
547             # initiate baremetal deployment
548             sudo opnfv-deploy -i  /root/inventory/pod_settings.yaml \
549             -d /usr/share/doc/opnfv/deploy_settings.yaml.example \
550             -n /root/network/network_settings.yaml
551
552             echo
553             echo "--------------------------------------------------------"
554             echo "Done!"
555
556 #######################
557 # trigger macros
558 ########################
559 - trigger:
560     name: 'apex-master'
561     triggers:
562         - timed: '0 3 * * *'