ced678ff993d7c3f97f8ad9dcc9df5dab0894312
[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             flags: '-fM'
18             disabled: false
19
20     project: 'apex'
21
22 - job-template:
23     name: 'apex-verify-{stream}'
24
25     node: opnfv-jump-1
26
27     logrotate:
28         daysToKeep: 30
29         numToKeep: 10
30         artifactDaysToKeep: -1
31         artifactNumToKeep: -1
32
33     parameters:
34         - apex-parameter:
35             gs-pathname: '{gs-pathname}'
36             flags: '{flags}'
37         - project-parameter:
38             project: '{project}'
39         - gerrit-parameter:
40             branch: '{branch}'
41         - string:
42             name: GIT_BASE
43             default: ssh://gerrit.opnfv.org:29418/$PROJECT
44             description: "Used for overriding the GIT URL coming from parameters macro."
45
46     scm:
47         - gerrit-trigger-scm:
48             credentials-id: '{ssh-credentials}'
49             refspec: '$GERRIT_REFSPEC'
50             choosing-strategy: 'gerrit'
51
52     triggers:
53         - gerrit:
54             trigger-on:
55                 - patchset-created-event:
56                     exclude-drafts: 'false'
57                     exclude-trivial-rebase: 'false'
58                     exclude-no-code-change: 'false'
59                 - draft-published-event
60                 - comment-added-contains-event:
61                     comment-contains-value: 'recheck'
62                 - comment-added-contains-event:
63                     comment-contains-value: 'reverify'
64             projects:
65               - project-compare-type: 'ANT'
66                 project-pattern: 'apex'
67                 branches:
68                   - branch-compare-type: 'ANT'
69                     branch-pattern: '**/master'
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
80     builders:
81         - 'apex-build'
82         - 'apex-deploy-virtual'
83         - 'apex-workspace-cleanup'
84
85 - job-template:
86     name: 'apex-merge-{stream}'
87
88     # builder-merge job to run JJB update
89     #
90     # This job's purpose is to update all the JJB
91
92     node: opnfv-jump-1
93
94     parameters:
95         - apex-parameter:
96             gs-pathname: '{gs-pathname}'
97             flags: '{flags}'
98         - project-parameter:
99             project: '{project}'
100         - gerrit-parameter:
101             branch: '{branch}'
102         - string:
103             name: GIT_BASE
104             default: ssh://gerrit.opnfv.org:29418/$PROJECT
105             description: "Used for overriding the GIT URL coming from parameters macro."
106
107     scm:
108         - gerrit-trigger-scm:
109             credentials-id: '{ssh-credentials}'
110             refspec: ''
111             choosing-strategy: 'default'
112
113     triggers:
114         - gerrit:
115             trigger-on:
116                 - change-merged-event
117                 - comment-added-contains-event:
118                     comment-contains-value: 'remerge'
119             projects:
120               - project-compare-type: 'ANT'
121                 project-pattern: 'apex'
122                 branches:
123                     - branch-compare-type: 'ANT'
124                       branch-pattern: '**/master'
125                 forbidden-file-paths:
126                   - compare-type: ANT
127                     pattern: 'docs/**'
128
129     builders:
130         - 'apex-build'
131         - 'apex-deploy-virtual'
132         - 'apex-workspace-cleanup'
133
134 - job-template:
135     name: 'apex-build-{stream}'
136
137     # Job template for builds
138     #
139     # Required Variables:
140     #     stream:    branch with - in place of / (eg. stable)
141     #     branch:    branch (eg. stable)
142     node: opnfv-jump-1
143
144     disabled: false
145
146     parameters:
147         - project-parameter:
148             project: '{project}'
149         - apex-parameter:
150             gs-pathname: '{gs-pathname}'
151             flags: '{flags}'
152         - gerrit-parameter:
153             branch: '{branch}'
154         - string:
155             name: GIT_BASE
156             default: ssh://gerrit.opnfv.org:29418/$PROJECT
157             description: "Used for overriding the GIT URL coming from parameters macro."
158
159     scm:
160         - git-scm:
161             credentials-id: '{ssh-credentials}'
162             refspec: ''
163             branch: '{branch}'
164
165     triggers:
166         - 'apex-{stream}'
167
168     builders:
169         - 'apex-build'
170         - 'apex-deploy-virtual'
171         - 'apex-upload-artifact'
172         - 'apex-workspace-cleanup'
173
174 - job-template:
175     name: 'apex-deploy-virtual-{stream}'
176
177     # Job template for virtual deployment
178     #
179     # Required Variables:
180     #     stream:    branch with - in place of / (eg. stable)
181     #     branch:    branch (eg. stable)
182     node: opnfv-jump-1
183
184     disabled: false
185
186     parameters:
187         - project-parameter:
188             project: '{project}'
189         - apex-parameter:
190             gs-pathname: '{gs-pathname}'
191             flags: '{flags}'
192
193     builders:
194         - 'apex-deploy-virtual'
195         - 'apex-workspace-cleanup'
196
197 - job-template:
198     name: 'apex-deploy-baremetal-{stream}'
199
200     # Job template for baremetal deployment
201     #
202     # Required Variables:
203     #     stream:    branch with - in place of / (eg. stable)
204     #     branch:    branch (eg. stable)
205     node: opnfv-jump-1
206
207     disabled: true
208
209     parameters:
210         - project-parameter:
211             project: '{project}'
212         - apex-parameter:
213             gs-pathname: '{gs-pathname}'
214             flags: '{flags}'
215
216     builders:
217         - 'apex-workspace-cleanup'
218
219 - job-template:
220     name: 'apex-daily-{stream}'
221
222     # Job template for daily build
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     parameters:
232         - project-parameter:
233             project: '{project}'
234         - apex-parameter:
235             gs-pathname: '{gs-pathname}'
236             flags: '{flags}'
237
238     properties:
239         - build-blocker:
240             use-build-blocker: true
241             blocking-jobs:
242                 - "apex-daily.*"
243     builders:
244         - trigger-builds:
245           - project: 'apex-build-{stream}'
246             git-revision: true
247             block: true
248         - trigger-builds:
249           - project: 'apex-deploy-virtual-{stream}'
250             git-revision: true
251             block: true
252         - trigger-builds:
253           - project: 'apex-deploy-baremetal-{stream}'
254         - trigger-builds:
255           - project: 'functest-apex-{stream}'
256             block: true
257             block-thresholds:
258                 build-step-failure-threshold: 'never'
259                 failure-threshold: 'never'
260                 unstable-threshold: 'FAILURE'
261
262 ########################
263 # parameter macros
264 ########################
265 - parameter:
266     name: apex-parameter
267     parameters:
268         - string:
269             name: ARTIFACT_NAME
270             default: 'latest'
271             description: "RPM Artifact name that will be appended to GS_URL to deploy a specific artifact"
272         - string:
273             name: BUILD_DIRECTORY
274             default: $WORKSPACE/build_output
275             description: "Directory where the build artifact will be located upon the completion of the build."
276         - string:
277             name: CACHE_DIRECTORY
278             default: $HOME/opnfv/cache/{gs-pathname}
279             description: "Directory where the cache to be used during the build is located."
280         - string:
281             name: GIT_BASE
282             default: https://gerrit.opnfv.org/gerrit/$PROJECT
283             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
284         - string:
285             name: GS_URL
286             default: artifacts.opnfv.org/$PROJECT/{gs-pathname}
287             description: "URL to Google Storage."
288         - string:
289             name: FLAGS
290             default: '{flags}'
291             description: "Build Flags"
292
293 ########################
294 # builder macros
295 ########################
296 - builder:
297     name: 'apex-build'
298     builders:
299         - shell: |
300             #!/bin/bash
301             set -o errexit
302             set -o nounset
303             set -o pipefail
304             # log info to console
305             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
306             echo "---------------------------------------------------------------------------------------"
307             echo "Build flags for this build are ${FLAGS}"
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 $FLAGS -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=$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             sudo opnfv-deploy -v
428
429             echo
430             echo "--------------------------------------------------------"
431             echo "Done!"
432
433 #######################
434 # trigger macros
435 ########################
436 - trigger:
437     name: 'apex-master'
438     triggers:
439         - timed: '0 3 * * *'