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