Fix ONAP verify job
[infra/cicd.git] / jjb / cloud-infra / onap-jobs / onap-verify-deploy-test.yaml
1 ---
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2019 Nordix Foundation.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19
20 - project:
21     name: 'onap-verify-deploy-test'
22
23     project: 'onap-verify-deploy-test'
24
25     stream:
26       - 'master':
27           branch: '{stream}'
28           k8s-version: '1.15'
29           deploy-scenario: 'onap-sdc-nofeature'
30       - 'frankfurt':
31           branch: '{stream}'
32           k8s-version: '1.15'
33           deploy-scenario: 'onap-sdc-nofeature'
34       - 'elalto':
35           branch: '{stream}'
36           k8s-version: '1.15'
37           deploy-scenario: 'onap-sdc-nofeature'
38
39     environment-type:
40       - online:
41           disabled: false
42           execution-mode: online-deployment
43           successful: false
44           failed: false
45           unstable: false
46           notbuilt: false
47       - offline:
48           disabled: false
49           execution-mode: offline-deployment
50           successful: false
51           failed: false
52           unstable: false
53           notbuilt: false
54     # just deploy phase for now and ONAP testing isn't defined yet
55     phase:
56       - deploy
57
58
59     type:
60       - cloud:
61           provisioner-type: 'heat'
62           slave-type: 'jumphost'
63           gated-projects: 'infra/stack/onap|infra/installer/oom'
64           pdf: "https://gerrit.nordix.org/gitweb?p=infra/provisioner/heat.git;a=blob_plain;f=playbooks/roles/create-stack/files/heat-environment-ci-city-ubuntu1804-onap.yaml"
65           idf: "https://gerrit.nordix.org/gitweb?p=infra/provisioner/heat.git;a=blob_plain;f=playbooks/roles/create-stack/files/heat-idf.yaml"
66
67     distro:
68       - ubuntu1804
69
70     cloud:
71       - city:
72           openrc-credentials-file: 'est-jenkins-openrcfile-city-frankfurt-cicd'
73
74     # This should be
75     dependency-jobs: 'onap-verify-package-{distro}-{stream}'
76     dependency-job-var: 'TRIGGER_onap_verify_package_{distro}_{stream}_BUILD_RESULT'
77
78     jobs:
79       - 'onap-verify-{environment-type}-deploy-test-{distro}-{cloud}-{type}-{stream}'
80       - 'onap-verify-{environment-type}-deploy-{distro}-{cloud}-{type}-{stream}'
81       - 'onap-verify-{environment-type}-deployk8s-{distro}-{cloud}-{type}-{stream}'
82
83 - job-template:
84     name: 'onap-verify-{environment-type}-deploy-test-{distro}-{cloud}-{type}-{stream}'
85
86     project-type: multijob
87
88     disabled: '{obj:disabled}'
89
90     concurrent: true
91
92     parameters:
93       - string:
94           name: DEPLOY_SCENARIO
95           default: '{deploy-scenario}'
96           description: 'Scenario to test change with.'
97       - string:
98           name: K8S_VERSION
99           default: '{k8s-version}'
100           description: 'K8S version to use for this deployment'
101       - string:
102           name: INVENTORY_INI
103           default: /tmp/inventory.ini
104           description: 'Location of the inventory file. Copied from k8s install'
105       - string:
106           name: DISTRO
107           default: '{distro}'
108           description: 'Distribution to use for configuring target nodes (networking etc.)'
109       - label:
110           name: SLAVE_LABEL
111           default: 'engine-{slave-type}-{environment-type}-{distro}-fra'
112           description: 'Slave label to schedule this job on.'
113       - string:
114           name: HW_TYPE
115           default: '{type}'
116           description: 'Hardware type - could be virtual, cloud, or baremetal'
117       - string:
118           name: EXECUTION_MODE
119           default: '{execution-mode}'
120           description: 'Execution mode to run in'
121       - string:
122           name: PDF
123           default: '{pdf}'
124           description: 'PDF file to use for deployment'
125       - string:
126           name: IDF
127           default: '{idf}'
128           description: 'IDF file to use for deployment'
129       - string:
130           name: HEAT_STACK_NAME
131           default: "nordix-cicd-verify-onap-{environment-type}-{distro}-$GERRIT_CHANGE_NUMBER"
132           description: 'Name of the created stack'
133       - string:
134           name: KEYPAIR_NAME
135           default: "keypair-nordix-cicd-verify-onap-{environment-type}-{distro}-$GERRIT_CHANGE_NUMBER"
136           description: 'Name of the created keypair'
137       - string:
138           name: USE_PREBUILT_DEPLOYMENT_IMAGE
139           default: 'true'
140           description: 'Use prebuilt deployment image while running as part of CI/CD'
141       - string:
142           name: TEST_REPO_URL
143           default: 'https://gerrit.nordix.org/infra/test.git'
144           description: 'URL to clone the test repo from'
145       - string:
146           name: TEST_FW
147           default: 'functest'
148           description: 'Test framework to use'
149       - string:
150           name: TEST_SUITE
151           default: 'healthcheck'
152           description: 'Test suite to run'
153       - string:
154           name: YARDSTICK_DISPATCHER
155           default: 'file'
156           description: 'Dispatcher to use for Yardstick reporting'
157       - string:
158           name: DELETE_STACK
159           default: 'true'
160           description: 'Delete the stack upon completion of the build'
161       - string:
162           name: VERBOSITY
163           default: 'true'
164           description: 'Verbosity setting for the engine - true or false - default is false'
165       - string:
166           name: CI_LOOP
167           default: "verify"
168           description: 'CI loop the job belongs to'
169       - project-parameters:
170           project: $GERRIT_PROJECT
171           branch: '{branch}'
172           description: 'The project and branch which the change is proposed for'
173       - nordix-gerrit-parameters
174
175     properties:
176       - logrotate
177       # NOTE (fdegir): throttle categories are controlled in jenkins global configuration
178       - throttle:
179           enabled: true
180           max-per-node: 1
181           max-total: 8
182           option: category
183           categories:
184             - engine-verify-deploy-test
185
186     scm:
187       - git-scm-gerrit:
188           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
189           branch: $GERRIT_BRANCH
190           refspec: $GERRIT_REFSPEC
191           wipe_workspace: true
192           clean_before: false
193
194     triggers:
195       - gerrit:
196           server-name: 'Nordix Gerrit'
197           trigger-on:
198             - patchset-created-event:
199                 exclude-drafts: 'false'
200                 exclude-trivial-rebase: 'false'
201                 exclude-no-code-change: 'false'
202             - draft-published-event
203             - comment-added-contains-event:
204                 comment-contains-value: 'recheck'
205             - comment-added-contains-event:
206                 comment-contains-value: 'reverify'
207           projects:
208             - project-compare-type: 'REG_EXP'
209               project-pattern: '{gated-projects}'
210               branches:
211                 - branch-compare-type: 'ANT'
212                   branch-pattern: '**/{branch}'
213               disable-strict-forbidden-file-verification: 'true'
214               forbidden-file-paths:
215                 - compare-type: ANT
216                   pattern: 'docs/**|releasenotes/**'
217           skip-vote:
218             successful: '{obj:successful}'
219             failed: '{obj:failed}'
220             unstable: '{obj:unstable}'
221             notbuilt: '{obj:notbuilt}'
222           custom-url: '* $JOB_NAME $BUILD_URL'
223           readable-message: 'true'
224           dependency-jobs: '{dependency-jobs}'
225
226     wrappers:
227       - build-timeout:
228           timeout: 180
229       - credentials-binding:
230           - file:
231               credential-id: '{openrc-credentials-file}'
232               variable: OPENRC_FILE
233           - username-password-separated:
234               credential-id: 'nordix-cicd-arm-credentials'
235               username: NORDIX_ARM_USERNAME
236               password: NORDIX_ARM_TOKEN
237       - mask-passwords
238       - openstack:
239           single-use: True
240       - pre-scm-buildstep:
241           failOnError: true
242           buildsteps:
243             - system-groovy:
244                 command: |
245                   def build = this.getProperty('binding').getVariable('build')
246                   def listener = this.getProperty('binding').getVariable('listener')
247                   if (build.getEnvironment(listener).{dependency-job-var} != "SUCCESS") {{
248                     println "WARN  : Aborting build since dependent job did not succeed!"
249                     throw new InterruptedException()
250                   }}
251             - shell: |
252                 #!/bin/bash
253                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
254                 # offline nodes can not resolve Nordix Artifactory and Gerrit
255                 if [[ "$EXECUTION_MODE" == "offline-deployment" ]]; then
256                   echo "Info  : Offline deployment. Adding City OpenStack Endpoint, Nordix Artifactory and Gerrit Public IP to /etc/hosts"
257                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
258                   sudo bash -c "cat << EOF >> /etc/hosts
259                 # managed by engine
260                 91.106.198.25 artifactory.nordix.org
261                 91.106.198.142 gerrit.nordix.org
262                 86.107.242.50 fra1.citycloud.com
263                 # managed by engine
264                 EOF"
265                   # we need to get rid of search domain as well
266                   sudo sed -i 's/^search/# search/' /etc/resolv.conf
267                 fi
268
269     builders:
270       - 'generate-change-metadata-macro'
271       - 'generate-k8sdeployment-environment-macro'
272       - multijob:
273           name: "{environment-type} deployment on {type} instances"
274           condition: SUCCESSFUL
275           execution-type: SEQUENTIAL
276           projects:
277             - name: 'onap-verify-{environment-type}-deployk8s-{distro}-{cloud}-{type}-{stream}'
278               current-parameters: true
279               git-revision: true
280               node-parameters: true
281               kill-phase-on: FAILURE
282               abort-all-job: false
283               property-file: $WORKSPACE/k8s.properties
284             - name: 'onap-verify-{environment-type}-deploy-{distro}-{cloud}-{type}-{stream}'
285               current-parameters: true
286               git-revision: true
287               node-parameters: true
288               kill-phase-on: FAILURE
289               abort-all-job: false
290               property-file: $WORKSPACE/change.properties
291     publishers:
292       - postbuildscript:
293           builders:
294             - role: SLAVE
295               build-on:
296                 - SUCCESS
297                 - FAILURE
298                 - ABORTED
299                 - NOT_BUILT
300                 - UNSTABLE
301               build-steps:
302                 - 'wait-pkg-mgr-macro'
303                 - 'delete-stack-macro'
304
305 - job-template:
306     name: 'onap-verify-{environment-type}-deploy-{distro}-{cloud}-{type}-{stream}'
307
308     disabled: '{obj:disabled}'
309
310     concurrent: true
311
312     properties:
313       - logrotate
314       - throttle:
315           max-per-node: 1
316           max-total: 3
317           option: project
318
319     scm:
320       - git-scm-gerrit:
321           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
322           branch: $GERRIT_BRANCH
323           refspec: $GERRIT_REFSPEC
324           wipe_workspace: true
325           clean_before: false
326
327     wrappers:
328       - build-timeout:
329           timeout: 180
330       - credentials-binding:
331           - file:
332               credential-id: '{openrc-credentials-file}'
333               variable: OPENRC_FILE
334           - username-password-separated:
335               credential-id: 'nordix-cicd-arm-credentials'
336               username: NORDIX_ARM_USERNAME
337               password: NORDIX_ARM_TOKEN
338       - mask-passwords
339       - fix-workspace-permissions
340
341     builders:
342       - 'generate-ssh-keypair-macro'
343       - 'wait-pkg-mgr-macro'
344       - 'download-deploy-artifact-macro'
345       - 'deploy-macro'
346
347 - job-template:
348     name: 'onap-verify-{environment-type}-deployk8s-{distro}-{cloud}-{type}-{stream}'
349
350     disabled: '{obj:disabled}'
351
352     concurrent: true
353
354     properties:
355       - logrotate
356       - throttle:
357           max-per-node: 1
358           max-total: 3
359           option: project
360
361     scm:
362       - git-scm-gerrit:
363           ssh-credentials-id: nordixinfra-nordix-gerrit-ssh
364           branch: $GERRIT_BRANCH
365           refspec: $GERRIT_REFSPEC
366           wipe_workspace: true
367           clean_before: false
368
369     wrappers:
370       - build-timeout:
371           timeout: 180
372       - credentials-binding:
373           - file:
374               credential-id: '{openrc-credentials-file}'
375               variable: OPENRC_FILE
376           - username-password-separated:
377               credential-id: 'nordix-cicd-arm-credentials'
378               username: NORDIX_ARM_USERNAME
379               password: NORDIX_ARM_TOKEN
380       - mask-passwords
381       - fix-workspace-permissions
382
383     builders:
384       - 'generate-ssh-keypair-macro'
385       - 'wait-pkg-mgr-macro'
386       - 'download-deploy-artifact-macro'
387       - 'deploy-macro'