d61f2a265fe6e375dd804cc1b6339213cd9004e3
[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         - trigger-builds:
311           - project: 'yardstick-apex-opnfv-jump-1-daily-{stream}'
312             block: true
313             block-thresholds:
314                 build-step-failure-threshold: 'never'
315                 failure-threshold: 'never'
316                 unstable-threshold: 'FAILURE'
317
318 ########################
319 # parameter macros
320 ########################
321 - parameter:
322     name: apex-parameter
323     parameters:
324         - string:
325             name: ARTIFACT_NAME
326             default: 'latest'
327             description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
328         - string:
329             name: ARTIFACT_VERSION
330             default: 'daily'
331             description: "Artifact version type"
332         - string:
333             name: BUILD_DIRECTORY
334             default: $WORKSPACE/build_output
335             description: "Directory where the build artifact will be located upon the completion of the build."
336         - string:
337             name: CACHE_DIRECTORY
338             default: $HOME/opnfv/cache{gs-pathname}
339             description: "Directory where the cache to be used during the build is located."
340         - string:
341             name: GIT_BASE
342             default: https://gerrit.opnfv.org/gerrit/$PROJECT
343             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
344         - string:
345             name: GS_URL
346             default: artifacts.opnfv.org/$PROJECT{gs-pathname}
347             description: "URL to Google Storage."
348
349 ########################
350 # builder macros
351 ########################
352 - builder:
353     name: 'apex-build'
354     builders:
355         - shell: |
356             #!/bin/bash
357             set -o errexit
358             set -o nounset
359             set -o pipefail
360             # log info to console
361             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
362             echo "---------------------------------------------------------------------------------------"
363             echo
364             # create the cache directory if it doesn't exist
365             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
366             # set OPNFV_ARTIFACT_VERSION
367             if echo $GERRIT_BRANCH | grep "brahmaputra" 1> /dev/null; then
368               export OPNFV_ARTIFACT_VERSION="bramaputra.1.rc0"
369             else
370               if [ "$ARTIFACT_VERSION" == "dev" ]; then
371                 export OPNFV_ARTIFACT_VERSION=dev${BUILD_NUMBER}
372               elif [ "$ARTIFACT_VERSION" == "daily" ]; then
373                 export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d")
374               else
375                 export OPNFV_ARTIFACT_VERSION=${ARTIFACT_VERSION}
376               fi
377             fi
378             # start the build
379             cd $WORKSPACE/ci
380             ./build.sh -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
381             RPM_VERSION=$(grep Version $BUILD_DIRECTORY/../build/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
382             # list the contents of BUILD_OUTPUT directory
383             ls -al $BUILD_DIRECTORY
384             # save information regarding artifact into file
385             (
386                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
387                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
388                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
389                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
390                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
391                 echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
392                 echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
393                 echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
394                 echo "OPNFV_BUILD_URL=$BUILD_URL"
395             ) > $WORKSPACE/opnfv.properties
396             echo
397             echo "--------------------------------------------------------"
398
399 - builder:
400     name: 'apex-workspace-cleanup'
401     builders:
402         - shell: |
403             #!/bin/bash
404             set -o errexit
405             set -o nounset
406             set -o pipefail
407
408             # delete everything that is in $WORKSPACE
409             /bin/rm -rf $WORKSPACE
410
411 - builder:
412     name: 'apex-upload-artifact'
413     builders:
414         - shell: |
415             #!/bin/bash
416             set -o errexit
417             set -o nounset
418             set -o pipefail
419
420             # log info to console
421             echo "Uploading the Apex artifact. This could take some time..."
422             echo "--------------------------------------------------------"
423             echo
424
425             # source the opnfv.properties to get ARTIFACT_VERSION
426             source $WORKSPACE/opnfv.properties
427
428             # upload artifact and additional files to google storage
429             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
430             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL) gs://$GS_URL/$(basename $OPNFV_RPM_URL) > gsutil.iso.log 2>&1
431             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_SRPM_URL) gs://$GS_URL/$(basename $OPNFV_SRPM_URL) > gsutil.iso.log 2>&1
432             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
433             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
434
435             echo
436             echo "--------------------------------------------------------"
437             echo "Done!"
438             echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
439             echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
440
441 - builder:
442     name: 'apex-deploy-virtual'
443     builders:
444         - shell: |
445             #!/bin/bash
446             set -o errexit
447             set -o nounset
448             set -o pipefail
449
450             # log info to console
451             echo "Starting the Apex virtual deployment."
452             echo "--------------------------------------------------------"
453             echo
454
455             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
456                 # if artifact name is passed the pull a
457                 # specific artifact from artifacts.opnfv.org
458                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
459             else
460                 if [[ -f opnfv.properties ]]; then
461                     # if opnfv.properties exists then use the
462                     # local build. Source the file so we get local OPNFV vars
463                     source opnfv.properties
464                     RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
465                 else
466                     # no opnfv.properties means use the latest from artifacts.opnfv.org
467                     # get the latest.properties to get the link to the latest artifact
468                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
469                     [[ -f opnfv.properties ]] || exit 1
470                     # source the file so we get OPNFV vars
471                     source opnfv.properties
472                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
473                 fi
474             fi
475
476             source opnfv.properties
477             RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
478
479             # update / install the new rpm
480             if rpm -q opnfv-apex > /dev/null; then
481                if sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
482                    sudo yum downgrade -y $RPM_INSTALL_PATH;
483                fi
484             else
485                sudo yum install -y $RPM_INSTALL_PATH;
486             fi
487
488             # cleanup virtual machines before we start
489             sudo opnfv-clean
490             # initiate virtual deployment
491             if [ -e /usr/share/doc/opnfv/network_settings.yaml.example ]; then
492               sudo opnfv-deploy -v -d /usr/share/doc/opnfv/deploy_settings.yaml.example -n /usr/share/doc/opnfv/network_settings.yaml.example
493             else
494               sudo opnfv-deploy -v
495             fi
496             echo
497             echo "--------------------------------------------------------"
498             echo "Done!"
499
500 - builder:
501     name: 'apex-deploy-baremetal'
502     builders:
503         - shell: |
504             #!/bin/bash
505             set -o errexit
506             set -o nounset
507             set -o pipefail
508
509             # log info to console
510             echo "Starting the Apex baremetal deployment."
511             echo "--------------------------------------------------------"
512             echo
513
514             if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
515                 # if artifact name is passed the pull a
516                 # specific artifact from artifacts.opnfv.org
517                 RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
518             else
519                 if [[ -f opnfv.properties ]]; then
520                     # if opnfv.properties exists then use the
521                     # local build. Source the file so we get local OPNFV vars
522                     source opnfv.properties
523                     RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
524                 else
525                     # no opnfv.properties means use the latest from artifacts.opnfv.org
526                     # get the latest.properties to get the link to the latest artifact
527                     curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
528                     [[ -f opnfv.properties ]] || exit 1
529                     # source the file so we get OPNFV vars
530                     source opnfv.properties
531                     RPM_INSTALL_PATH=$OPNFV_RPM_URL
532                 fi
533             fi
534
535             source opnfv.properties
536             RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
537             if [ ! -e "$RPM_INSTALL_PATH" ]; then
538                RPM_INSTALL_PATH=http://${OPNFV_RPM_URL}
539             fi
540
541             # update / install the new rpm
542             if rpm -q opnfv-apex > /dev/null; then
543                if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
544                  echo "RPM is already installed"
545                elif sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
546                    sudo yum downgrade -y $RPM_INSTALL_PATH;
547                fi
548             else
549                sudo yum install -y $RPM_INSTALL_PATH;
550             fi
551
552             # cleanup environment before we start
553             sudo opnfv-clean
554             # initiate baremetal deployment
555             sudo opnfv-deploy -i  /root/inventory/pod_settings.yaml \
556             -d /usr/share/doc/opnfv/deploy_settings.yaml.example \
557             -n /root/network/network_settings.yaml
558
559             echo
560             echo "--------------------------------------------------------"
561             echo "Done!"
562
563 #######################
564 # trigger macros
565 ########################
566 - trigger:
567     name: 'apex-master'
568     triggers:
569         - timed: '0 3 * * *'