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