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