blob: 7582e76d1dde1e635063bc46aa3eb74261e4ee63 [file] [log] [blame]
Luca Prete45401c82019-01-15 15:31:22 -08001// Copyright 2017-present Open Networking Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15node ("${TestNodeName}") {
16 timeout (100) {
17 try {
18 stage ("Parse deployment configuration file") {
Matteo Scandolo9f8056b2019-01-17 10:33:51 -080019 sh returnStdout: true, script: "rm -rf helm-charts helm-repo-tools ${configBaseDir}"
Luca Prete45401c82019-01-15 15:31:22 -080020 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools"
21 sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
22 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
23 }
24 stage('Clean up') {
25 timeout(10) {
26 sh returnStdout: true, script: """
27 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
28 for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
29 do
30 echo "Purging chart: \${hchart}"
31 helm delete --purge "\${hchart}"
32 done
33 """
34 timeout(5) {
35 waitUntil {
36 helm_deleted = sh returnStdout: true, script: """
37 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
38 helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
39 """
40 return helm_deleted.toInteger() == 0
41 }
42 }
Wei-Yu Chen9de5f162019-01-17 10:40:38 -080043 timeout(5) {
Luca Prete45401c82019-01-15 15:31:22 -080044 waitUntil {
45 kubectl_deleted = sh returnStdout: true, script: """
46 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
47 kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
48 """
49 return kubectl_deleted.toInteger() == 0
50 }
51 }
52 }
53 }
Luca Prete62a48c82019-01-16 10:40:01 -080054 stage('Add Helm repositories') {
Luca Prete45401c82019-01-15 15:31:22 -080055 sh returnStdout: true, script: """
56 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen76dd7932019-01-18 14:14:23 -080057 helm init --upgrade --force-upgrade
Luca Prete45401c82019-01-15 15:31:22 -080058 helm repo add cord https://charts.opencord.org
Luca Prete62a48c82019-01-16 10:40:01 -080059 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Luca Prete45401c82019-01-15 15:31:22 -080060 helm repo update
61 """
62 timeout(1) {
63 waitUntil {
Wei-Yu Chen76dd7932019-01-18 14:14:23 -080064 tillerpod_running = sh returnStdout: true, script: """
65 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
66 kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l
67 """
68 return tillerpod_running.toInteger() == 1
69 }
70 }
71 timeout(1) {
72 waitUntil {
Luca Prete45401c82019-01-15 15:31:22 -080073 cord_repo_present = sh returnStdout: true, script: """
74 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
75 helm repo list | grep cord | wc -l
76 """
77 return cord_repo_present.toInteger() == 1
78 }
79 }
80 }
Matteo Scandolo08aea472019-01-23 11:45:37 -080081
Wei-Yu Chen992665b2019-01-17 10:21:32 -080082 stage("Install M-CORD Control Plane Services") {
83 sh returnStdout: true, script: """
84 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
Wei-Yu Chen7f8c4dd2019-01-17 15:32:03 -080085 helm install -n mcord-control-plane --namespace epc -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-control-plane
Wei-Yu Chen992665b2019-01-17 10:21:32 -080086 """
Wei-Yu Chen037762d2019-01-24 11:12:39 -080087
Wei-Yu Chen037762d2019-01-24 11:12:39 -080088 timeout(20) {
89 control_plane = sh returnStdout: true, script: """
90 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
91 kubectl -n epc get pods | grep Running | grep 1/1 | wc -l
92 """
93 // We have 4 pods: cassandra, hss, mme and ngic-cp
94 return control_plane.toInteger() == 4
95 }
Luca Prete45401c82019-01-15 15:31:22 -080096 }
Wei-Yu Chen992665b2019-01-17 10:21:32 -080097
Luca Prete45401c82019-01-15 15:31:22 -080098 currentBuild.result = 'SUCCESS'
99 } catch (err) {
100 currentBuild.result = 'FAILURE'
101 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
102 }
103 echo "RESULT: ${currentBuild.result}"
104 }
105}