bf6d5e5a020e55d4c9ce5eefb58325763d18e43f
[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-workspace-cleanup'
193         - 'apex-deploy-virtual'
194         - 'apex-workspace-cleanup'
195
196 ########################
197 # parameter macros
198 ########################
199 - parameter:
200     name: apex-parameter
201     parameters:
202         - string:
203             name: BUILD_DIRECTORY
204             default: $WORKSPACE/build_output
205             description: "Directory where the build artifact will be located upon the completion of the build."
206         - string:
207             name: CACHE_DIRECTORY
208             default: $HOME/opnfv/cache/{gs-pathname}
209             description: "Directory where the cache to be used during the build is located."
210         - string:
211             name: GIT_BASE
212             default: https://gerrit.opnfv.org/gerrit/$PROJECT
213             description: "Used for overriding the GIT URL coming from Global Jenkins configuration in case if the stuff is done on none-LF HW."
214         - string:
215             name: GS_URL
216             default: artifacts.opnfv.org/$PROJECT/{gs-pathname}
217             description: "URL to Google Storage."
218         - string:
219             name: FLAGS
220             default: '{flags}'
221             description: "Build Flags"
222
223 ########################
224 # builder macros
225 ########################
226 - builder:
227     name: 'apex-build'
228     builders:
229         - shell: |
230             #!/bin/bash
231             set -o errexit
232             set -o nounset
233             set -o pipefail
234             # log info to console
235             echo "Starting the build of Apex using OpenStack Master packages. This will take some time..."
236             echo "---------------------------------------------------------------------------------------"
237             echo "Build flags for this build are ${FLAGS}"
238             echo "---------------------------------------------------------------------------------------"
239             echo
240             # create the cache directory if it doesn't exist
241             [[ -d $CACHE_DIRECTORY ]] || mkdir -p $CACHE_DIRECTORY
242             # set OPNFV_ARTIFACT_VERSION
243             export OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
244             # start the build
245             cd $WORKSPACE/ci
246             ./build.sh $FLAGS -v $OPNFV_ARTIFACT_VERSION -c file://$CACHE_DIRECTORY $BUILD_DIRECTORY
247             RPM_VERSION=$(grep Version $BUILD_DIRECTORY/../build/opnfv-apex.spec | awk '{ print $2 }')-$(echo $OPNFV_ARTIFACT_VERSION | tr -d '_-')
248             # list the contents of BUILD_OUTPUT directory
249             ls -al $BUILD_DIRECTORY
250             # save information regarding artifact into file
251             (
252                 echo "OPNFV_ARTIFACT_VERSION=$OPNFV_ARTIFACT_VERSION"
253                 echo "OPNFV_GIT_URL=$(git config --get remote.origin.url)"
254                 echo "OPNFV_GIT_SHA1=$(git rev-parse HEAD)"
255                 echo "OPNFV_ARTIFACT_URL=$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
256                 echo "OPNFV_ARTIFACT_MD5SUM=$(md5sum $BUILD_DIRECTORY/OPNFV-CentOS-7-x86_64-$OPNFV_ARTIFACT_VERSION.iso | cut -d' ' -f1)"
257                 echo "OPNFV_SRPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.src.rpm"
258                 echo "OPNFV_RPM_URL=$GS_URL/opnfv-apex-$RPM_VERSION.noarch.rpm"
259                 echo "OPNFV_RPM_MD5SUM=$(md5sum $BUILD_DIRECTORY/opnfv-apex-$RPM_VERSION.noarch.rpm | cut -d' ' -f1)"
260                 echo "OPNFV_BUILD_URL=$BUILD_URL"
261             ) > $WORKSPACE/opnfv.properties
262             echo
263             echo "--------------------------------------------------------"
264
265 - builder:
266     name: 'apex-workspace-cleanup'
267     builders:
268         - shell: |
269             #!/bin/bash
270             set -o errexit
271             set -o nounset
272             set -o pipefail
273
274             # delete everything that is in $WORKSPACE
275             /bin/rm -rf $WORKSPACE
276
277 - builder:
278     name: 'apex-upload-artifact'
279     builders:
280         - shell: |
281             #!/bin/bash
282             set -o errexit
283             set -o nounset
284             set -o pipefail
285
286             # log info to console
287             echo "Uploading the Apex artifact. This could take some time..."
288             echo "--------------------------------------------------------"
289             echo
290
291             # source the opnfv.properties to get ARTIFACT_VERSION
292             source $WORKSPACE/opnfv.properties
293
294             # upload artifact and additional files to google storage
295             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
296             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL) gs://$GS_URL/$(basename $OPNFV_RPM_URL) > gsutil.iso.log 2>&1
297             gsutil cp $BUILD_DIRECTORY/$(basename $OPNFV_SRPM_URL) gs://$GS_URL/$(basename $OPNFV_SRPM_URL) > gsutil.iso.log 2>&1
298             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
299             gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
300
301             echo
302             echo "--------------------------------------------------------"
303             echo "Done!"
304             echo "ISO Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
305             echo "RPM Artifact is available as http://$GS_URL/$(basename $OPNFV_RPM_URL)"
306
307 - builder:
308     name: 'apex-deploy-virtual'
309     builders:
310         - shell: |
311             #!/bin/bash
312             set -o errexit
313             set -o nounset
314             set -o pipefail
315
316             # log info to console
317             echo "Starting the Apex virtual deployment."
318             echo "--------------------------------------------------------"
319             echo
320
321             # check if we got the file
322             if [[ -f opnfv.properties ]]; then
323                 # source the file so we get OPNFV vars
324                 source opnfv.properties
325                 RPM_INSTALL_PATH=noarch/$(basepath RPM_URL)
326             else
327                 # get the latest.properties file in order to get info regarding latest artifact
328                 curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
329                 [[ -f opnfv.properties ]] || exit 1
330
331                 # source the file so we get OPNFV vars
332                 source opnfv.properties
333                 RPM_INSTALL_PATH=$RPM_URL
334             fi
335
336             # update / install the new rpm
337             if rpm -q opnfv-apex; then
338                sudo yum update -y $RPM_INSTALL_PATH;
339             else
340                sudo yum install -y $RPM_INSTALL_PATH;
341             fi
342
343             # cleanup virtual machines before we start
344             sudo opnfv-clean
345             # initiate virtual deployment
346             sudo opnfv-deploy -v
347
348             echo
349             echo "--------------------------------------------------------"
350             echo "Done!"
351
352 #######################
353 # trigger macros
354 ########################
355 - trigger:
356     name: 'apex-master'
357     triggers:
358         - timed: '0 3 * * *'