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