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