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