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