Add Functest execution after APEX deployment
[releng.git] / jjb / apex / apex.yml
1 - project:
2     name: apex
3     jobs:
4         - 'apex-verify-{stream}'
5         - 'apex-merge-{stream}'
6         - 'apex-daily-{stream}'
7
8     # stream:    branch with - in place of / (eg. stable-arno)
9     # branch:    branch (eg. stable/arno)
10     stream:
11         - master:
12             branch: 'master'
13             gs-pathname: ''
14             flags: '-fM'
15             disabled: false
16
17     project: 'apex'
18
19 - job-template:
20     name: 'apex-verify-{stream}'
21
22     node: opnfv-jump-1
23
24     project-type: freestyle
25
26     logrotate:
27         daysToKeep: 30
28         numToKeep: 10
29         artifactDaysToKeep: -1
30         artifactNumToKeep: -1
31
32     parameters:
33         - apex-parameter:
34             gs-pathname: '{gs-pathname}'
35             flags: '{flags}'
36         - project-parameter:
37             project: '{project}'
38         - gerrit-parameter:
39             branch: '{branch}'
40         - string:
41             name: GIT_BASE
42             default: ssh://gerrit.opnfv.org:29418/$PROJECT
43             description: "Used for overriding the GIT URL coming from parameters macro."
44
45     scm:
46         - gerrit-trigger-scm:
47             credentials-id: '{ssh-credentials}'
48             refspec: '$GERRIT_REFSPEC'
49             choosing-strategy: 'gerrit'
50
51     wrappers:
52         - ssh-agent-credentials:
53             user: '{ssh-credentials}'
54
55     triggers:
56         - gerrit:
57             trigger-on:
58                 - patchset-created-event:
59                     exclude-drafts: 'false'
60                     exclude-trivial-rebase: 'false'
61                     exclude-no-code-change: 'false'
62                 - draft-published-event
63                 - comment-added-contains-event:
64                     comment-contains-value: 'recheck'
65                 - comment-added-contains-event:
66                     comment-contains-value: 'reverify'
67             projects:
68               - project-compare-type: 'ANT'
69                 project-pattern: 'apex'
70                 branches:
71                   - branch-compare-type: 'ANT'
72                     branch-pattern: '**/master'
73                 forbidden-file-paths:
74                   - compare-type: ANT
75                     pattern: 'docs/**'
76
77     builders:
78         - 'apex-build'
79         - 'apex-deploy-virtual'
80         - 'apex-workspace-cleanup'
81
82 - job-template:
83     name: 'apex-merge-{stream}'
84
85     # builder-merge job to run JJB update
86     #
87     # This job's purpose is to update all the JJB
88
89     node: opnfv-jump-1
90
91     project-type: freestyle
92
93     logrotate:
94         daysToKeep: 30
95         numToKeep: 40
96         artifactDaysToKeep: -1
97         artifactNumToKeep: 5
98
99     parameters:
100         - apex-parameter:
101             gs-pathname: '{gs-pathname}'
102             flags: '{flags}'
103         - project-parameter:
104             project: '{project}'
105         - gerrit-parameter:
106             branch: '{branch}'
107         - string:
108             name: GIT_BASE
109             default: ssh://gerrit.opnfv.org:29418/$PROJECT
110             description: "Used for overriding the GIT URL coming from parameters macro."
111
112     scm:
113         - gerrit-trigger-scm:
114             credentials-id: '{ssh-credentials}'
115             refspec: ''
116             choosing-strategy: 'default'
117
118     wrappers:
119         - ssh-agent-credentials:
120             user: '{ssh-credentials}'
121
122     triggers:
123         - gerrit:
124             trigger-on:
125                 - change-merged-event
126                 - comment-added-contains-event:
127                     comment-contains-value: 'remerge'
128             projects:
129               - project-compare-type: 'ANT'
130                 project-pattern: 'apex'
131                 branches:
132                     - branch-compare-type: 'ANT'
133                       branch-pattern: '**/master'
134                 forbidden-file-paths:
135                   - compare-type: ANT
136                     pattern: 'docs/**'
137
138     builders:
139         - 'apex-build'
140         - 'apex-deploy-virtual'
141         - 'apex-workspace-cleanup'
142
143 - job-template:
144     name: 'apex-daily-{stream}'
145
146     # Job template for daily builders
147     #
148     # Required Variables:
149     #     stream:    branch with - in place of / (eg. stable)
150     #     branch:    branch (eg. stable)
151     node: opnfv-jump-1
152
153     disabled: false
154
155     project-type: freestyle
156
157     logrotate:
158         daysToKeep: '{build-days-to-keep}'
159         numToKeep: '{build-num-to-keep}'
160         artifactDaysToKeep: '{build-artifact-days-to-keep}'
161         artifactNumToKeep: '{build-artifact-num-to-keep}'
162
163     parameters:
164         - project-parameter:
165             project: '{project}'
166         - apex-parameter:
167             gs-pathname: '{gs-pathname}'
168             flags: '{flags}'
169         - gerrit-parameter:
170             branch: '{branch}'
171         - string:
172             name: GIT_BASE
173             default: ssh://gerrit.opnfv.org:29418/$PROJECT
174             description: "Used for overriding the GIT URL coming from parameters macro."
175
176     scm:
177         - git-scm:
178             credentials-id: '{ssh-credentials}'
179             refspec: ''
180             branch: '{branch}'
181
182     wrappers:
183         - ssh-agent-credentials:
184             user: '{ssh-credentials}'
185
186     triggers:
187         - 'apex-{stream}'
188
189     builders:
190         - 'apex-build'
191         - 'apex-upload-artifact'
192         - 'apex-deploy-virtual'
193         - 'apex-workspace-cleanup'
194         - trigger-builds:
195           - project: 'functest-apex-{stream}'
196             block: true
197             block-thresholds:
198                 build-step-failure-threshold: 'never'
199                 failure-threshold: 'never'
200                 unstable-threshold: 'FAILURE'
201
202 ########################
203 # parameter macros
204 ########################
205 - parameter:
206     name: apex-parameter
207     parameters:
208         - string:
209             name: BUILD_DIRECTORY
210             default: $WORKSPACE/build_output
211             description: "Directory where the build artifact will be located upon the completion of the build."
212         - string:
213             name: CACHE_DIRECTORY
214             default: $HOME/opnfv/cache/{gs-pathname}
215             description: "Directory where the cache to be used during the build is located."
216         - string:
217             name: GIT_BASE
218             default: https://gerrit.opnfv.org/gerrit/$PROJECT
219             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
220         - string:
221             name: GS_URL
222             default: artifacts.opnfv.org/$PROJECT/{gs-pathname}
223             description: "URL to Google Storage."
224         - string:
225             name: FLAGS
226             default: '{flags}'
227             description: "Build Flags"
228
229 ########################
230 # builder macros
231 ########################
232 - builder:
233     name: 'apex-build'
234     builders:
235         - shell: |
236             #!/bin/bash
237             set -o errexit
238             set -o nounset
239             set -o pipefail
240             # log info to console
241             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
242             echo "---------------------------------------------------------------------------------------"
243             echo "Build flags for this build are ${FLAGS}"
244             echo "---------------------------------------------------------------------------------------"
245             echo
246             # create the cache directory if it doesn't exist
247             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
248             # set OPNFV_ARTIFACT_VERSION
249             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
250             # start the build
251             cd $WORKSPACE/ci
252             ./build.sh $FLAGS -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
253             RPM_VERSION=$(grep Version $BUILD_DIRECTORY/../build/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
254             # list the contents of BUILD_OUTPUT directory
255             ls -al $BUILD_DIRECTORY
256             # save information regarding artifact into file
257             (
258                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
259                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
260                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
261                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
262                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
263                 echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
264                 echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
265                 echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
266                 echo "OPNFV_BUILD_URL=$BUILD_URL"
267             ) > $WORKSPACE/opnfv.properties
268             echo
269             echo "--------------------------------------------------------"
270
271 - builder:
272     name: 'apex-workspace-cleanup'
273     builders:
274         - shell: |
275             #!/bin/bash
276             set -o errexit
277             set -o nounset
278             set -o pipefail
279
280             # delete everything that is in $WORKSPACE
281             /bin/rm -rf $WORKSPACE
282
283 - builder:
284     name: 'apex-upload-artifact'
285     builders:
286         - shell: |
287             #!/bin/bash
288             set -o errexit
289             set -o nounset
290             set -o pipefail
291
292             # log info to console
293             echo "Uploading the Apex artifact. This could take some time..."
294             echo "--------------------------------------------------------"
295             echo
296
297             # source the opnfv.properties to get ARTIFACT_VERSION
298             source $WORKSPACE/opnfv.properties
299
300             # upload artifact and additional files to google storage
301             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
302             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL) gs://$GS_URL/$(basename $OPNFV_RPM_URL) > gsutil.iso.log 2>&1
303             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_SRPM_URL) gs://$GS_URL/$(basename $OPNFV_SRPM_URL) > gsutil.iso.log 2>&1
304             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
305             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
306
307             echo
308             echo "--------------------------------------------------------"
309             echo "Done!"
310             echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
311             echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
312
313 - builder:
314     name: 'apex-deploy-virtual'
315     builders:
316         - shell: |
317             #!/bin/bash
318             set -o errexit
319             set -o nounset
320             set -o pipefail
321
322             # log info to console
323             echo "Starting the Apex virtual deployment."
324             echo "--------------------------------------------------------"
325             echo
326
327             # check if we got the file
328             if [[ -f opnfv.properties ]]; then
329                 # source the file so we get OPNFV vars
330                 source opnfv.properties
331                 RPM_INSTALL_PATH=build_output/$(basename $OPNFV_RPM_URL)
332             else
333                 # get the latest.properties file in order to get info regarding latest artifact
334                 curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
335                 [[ -f opnfv.properties ]] || exit 1
336
337                 # source the file so we get OPNFV vars
338                 source opnfv.properties
339                 RPM_INSTALL_PATH=$RPM_URL
340             fi
341
342             # update / install the new rpm
343             if rpm -q opnfv-apex > /dev/null; then
344                if sudo yum update -y $RPM_INSTALL_PATH | grep "does not update installed package"; then
345                    sudo yum downgrade -y $RPM_INSTALL_PATH;
346                fi
347             else
348                sudo yum install -y $RPM_INSTALL_PATH;
349             fi
350
351             # cleanup virtual machines before we start
352             sudo opnfv-clean
353             # initiate virtual deployment
354             sudo opnfv-deploy -v
355
356             echo
357             echo "--------------------------------------------------------"
358             echo "Done!"
359
360 #######################
361 # trigger macros
362 ########################
363 - trigger:
364     name: 'apex-master'
365     triggers:
366         - timed: '0 3 * * *'