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