Add jenkins charts
[it/dep.git] / smo-install / jenkins / github / automatic-verify-pipeline
1 lock('smo') {
2 podTemplate(yaml: '''
3               apiVersion: v1
4               kind: Pod
5               spec:
6                 containers:
7                 - name: jenkins-ubuntu
8                   image: ubuntu:20.04
9                   command:
10                   - sleep
11                   args: 
12                   - 99d
13 ''') {
14   node(POD_LABEL) {
15       
16       def proxies=''
17       sh 'printenv'
18       stage('Checkout') {
19         script {
20           if (env.BRANCH_NAME.startsWith('PR-')) {
21             echo 'PULL REQUEST case detected'
22             gitInfo =  checkout([$class: 'GitSCM', branches: [[name: 'pr/'+env.CHANGE_ID]], extensions: [[$class: 'SubmoduleOption', recursiveSubmodules: true]], userRemoteConfigs: [[credentialsId: 'github_username_pass', name: 'origin', refspec: '+refs/pull/*/head:refs/remotes/origin/pr/*', url: 'https://github.com/sebdet/oran-deployment.git']]])
23
24           } else {
25             echo 'BRANCH case detected'
26             gitInfo =  checkout([$class: 'GitSCM', branches: [[name: env.BRANCH_NAME]], extensions: [[$class: 'SubmoduleOption', recursiveSubmodules: true]], userRemoteConfigs: [[credentialsId: 'github_username_pass', name: 'origin', refspec: '+refs/heads/*:refs/remotes/origin/*', url: 'https://github.com/sebdet/oran-deployment.git']]])
27           }
28         }
29         echo "Test: "+ gitInfo
30         githubNotify context:env.HUDSON_URL, description:'Validating SMO package', repo:'oran-deployment', account: 'sebdet', status:'PENDING', sha:gitInfo.GIT_COMMIT, credentialsId:'github_username_pass'
31
32       }
33       container('jenkins-ubuntu') {
34         stage ('Proxy settings') {
35           echo 'Proxy check'
36           script {
37             if (env.http_proxy) {
38               sh 'echo \'Acquire::http::Proxy "' + env.http_proxy + '";\' > /etc/apt/apt.conf.d/proxy.conf'
39               sh 'cat /etc/apt/apt.conf.d/proxy.conf'
40               sh 'echo "http_proxy = "'+env.http_proxy+' > ~/.wgetrc'
41               sh 'cat ~/.wgetrc'
42
43               sh 'echo \'Acquire::https::Proxy "' + env.http_proxy + '";\' >> /etc/apt/apt.conf.d/proxy.conf'
44               sh 'cat /etc/apt/apt.conf.d/proxy.conf'         
45               sh 'echo "https_proxy = "'+env.http_proxy+' >> ~/.wgetrc'
46               sh 'cat ~/.wgetrc'
47               
48               proxies='HTTPS_PROXY='+env.http_proxy+' '
49             }
50           }
51           sh 'printenv'
52
53         }
54         stage('Setup tools') {
55             echo 'Setup container'
56             sh 'printenv'
57
58             sh 'apt-get update -y'
59             sh 'DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata'
60             sh 'apt-get install git wget sudo -y'
61  
62             sh 'wget https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl'
63             sh 'mv kubectl /usr/bin'
64             sh 'chmod a+x /usr/bin/kubectl'
65
66             sh proxies+' ./scripts/layer-0/0-setup-tests-env.sh'
67             sh proxies+' ./scripts/layer-0/0-setup-charts-museum.sh'
68             sh proxies+' ./scripts/layer-0/0-setup-helm3.sh'
69             sh 'kubectl version'
70         }
71         stage('Build ONAP charts') {
72             sh proxies+' ./scripts/sub-scripts/build-onap.sh'
73         }
74         stage('Build ORAN charts') {
75             sh proxies+' ./scripts/sub-scripts/build-oran.sh'
76         }
77         stage('Build TESTS charts') {
78             sh proxies+' ./scripts/sub-scripts/build-tests.sh'
79         }
80         stage('Start SMO') {
81             sh './scripts/layer-2/2-install-oran.sh pythonsdk-tests'
82         }
83         stage('Test ORAN') {
84             dir("test/pythonsdk") {
85               try {
86                 if (env.http_proxy) {
87                   sh proxies+' NO_PROXY='+env.no_proxy+' tox'
88                 } else {
89                   sh 'tox'
90                 }
91                 githubNotify context:env.HUDSON_URL, description:'SMO Package build SUCCESSFUL', repo:'oran-deployment', account: 'sebdet', status:'SUCCESS', sha:gitInfo.GIT_COMMIT, credentialsId:'github_username_pass'
92                 currentBuild.result = 'SUCCESS'
93               }
94               catch(exec) {
95                 echo 'TOX tests crashed'
96                 githubNotify context:env.HUDSON_URL, description:'SMO Package build FAILED, TOX tests crashed', repo:'oran-deployment', account: 'sebdet', status:'FAILURE', sha:gitInfo.GIT_COMMIT, credentialsId:'github_username_pass'
97                 currentBuild.result = 'FAILURE'
98               }
99             }
100         }
101         stage('Stop SMO') {
102           sh './scripts/sub-scripts/uninstall-nonrtric.sh'
103           sh './scripts/sub-scripts/uninstall-onap.sh'
104         }
105         stage('Get Results') {
106           archiveArtifacts artifacts: 'test/pythonsdk/src/orantests/pythonsdk.debug.log, **/reports/junit/*.xml', fingerprint: true
107           junit '**/reports/junit/*.xml'
108
109         }
110       }
111    
112   }
113 }
114 }
115
116