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