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