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