--- /dev/null
+lock('smo') {
+podTemplate(yaml: '''
+ apiVersion: v1
+ kind: Pod
+ spec:
+ containers:
+ - name: jenkins-ubuntu
+ image: ubuntu:20.04
+ command:
+ - sleep
+ args:
+ - 99d
+''') {
+ node(POD_LABEL) {
+
+ def proxies=''
+ def toxLog=''
+ sh 'printenv'
+ stage('Checkout') {
+ script {
+ if (env.GERRIT_REFNAME.startsWith('refs/changes/')) {
+ echo 'PULL REQUEST case detected'
+ gitInfo = checkout([$class: 'GitSCM', branches: [[name: 'changes/'+env.BRANCH_NAME]], extensions: [[$class: 'SubmoduleOption', recursiveSubmodules: true]], userRemoteConfigs: [[credentialsId: 'gerrit_username_pass', name: 'origin', refspec: '+refs/changes/*:refs/remotes/origin/changes/*', url: 'https://gerrit.o-ran-sc.org/r/a/it/dep']]])
+
+ } else {
+ echo 'BRANCH case detected'
+ gitInfo = checkout([$class: 'GitSCM', branches: [[name: env.BRANCH_NAME]], extensions: [[$class: 'SubmoduleOption', recursiveSubmodules: true]], userRemoteConfigs: [[credentialsId: 'gerrit_username_pass', name: 'origin', refspec: '+refs/heads/*:refs/remotes/origin/*', url: 'https://gerrit.o-ran-sc.org/r/a/it/dep']]])
+ }
+ }
+ echo "Git: "+ gitInfo
+ gerritReview labels: [Verified: 0], message: env.HUDSON_URL+': Validating the SMO package ' + env.BUILD_URL
+ }
+ container('jenkins-ubuntu') {
+ stage ('Proxy settings') {
+ echo 'Proxy check'
+ script {
+ if (env.http_proxy) {
+ sh 'echo \'Acquire::http::Proxy "' + env.http_proxy + '";\' > /etc/apt/apt.conf.d/proxy.conf'
+ sh 'cat /etc/apt/apt.conf.d/proxy.conf'
+ sh 'echo "http_proxy = "'+env.http_proxy+' > ~/.wgetrc'
+ sh 'cat ~/.wgetrc'
+
+ sh 'echo \'Acquire::https::Proxy "' + env.http_proxy + '";\' >> /etc/apt/apt.conf.d/proxy.conf'
+ sh 'cat /etc/apt/apt.conf.d/proxy.conf'
+ sh 'echo "https_proxy = "'+env.http_proxy+' >> ~/.wgetrc'
+ sh 'cat ~/.wgetrc'
+
+ proxies='HTTPS_PROXY='+env.http_proxy+' '
+ }
+ }
+ sh 'printenv'
+
+ }
+ stage('Setup tools') {
+ echo 'Setup container'
+ sh 'printenv'
+
+ sh 'apt-get update -y'
+ sh 'DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata'
+ sh 'apt-get install git wget sudo -y'
+
+ sh 'wget https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl'
+ sh 'mv kubectl /usr/bin'
+ sh 'chmod a+x /usr/bin/kubectl'
+
+ sh proxies+' ./smo-install/scripts/layer-0/0-setup-tests-env.sh'
+ sh proxies+' ./smo-install/scripts/layer-0/0-setup-charts-museum.sh'
+ sh proxies+' ./smo-install/scripts/layer-0/0-setup-helm3.sh'
+ sh 'kubectl version'
+ }
+ stage('Build ONAP charts') {
+ sh proxies+' ./smo-install/scripts/sub-scripts/build-onap.sh'
+ }
+ stage('Build ORAN charts') {
+ sh proxies+' ./smo-install/scripts/sub-scripts/build-oran.sh'
+ }
+ stage('Build TESTS charts') {
+ sh proxies+' ./smo-install/scripts/sub-scripts/build-tests.sh'
+ }
+ stage('Start SMO') {
+ sh './smo-install/scripts/layer-2/2-install-oran.sh pythonsdk-tests'
+ }
+ stage('Test ORAN') {
+ dir("smo-install/test/pythonsdk") {
+ echo 'Executing TOX tests'
+ try {
+ if (env.http_proxy) {
+ sh script: proxies+' NO_PROXY='+env.no_proxy+' tox > tox.log'
+ } else {
+ sh script: 'tox > tox.log'
+ }
+ echo 'TOX tests SUCCESS'
+ toxLog = readFile 'tox.log'
+ echo toxLog
+ toxLog = sh script: 'tail -40 tox.log',returnStdout: true
+
+ gerritReview labels: [Verified: 0], message:env.HUDSON_URL+': SMO Build SUCCESSFUL ('+env.BUILD_URL+')\r\n\r\n'+toxLog
+ //gerritCheck checks: ['SMO:checker': 'SUCCESSFUL']
+ currentBuild.result = 'SUCCESS'
+ }
+ catch(exec) {
+ echo 'TOX tests FAILURE'
+ toxLog = readFile 'tox.log'
+ echo toxLog
+ toxLog = sh script: 'tail -40 tox.log',returnStdout: true
+
+ gerritReview labels: [Verified: 0], message:env.HUDSON_URL+': SMO Build FAILED, TOX tests have crashed ('+env.BUILD_URL+')\r\n\r\n'+toxLog
+ //gerritCheck checks: ['SMO:checker': 'FAILED']
+ currentBuild.result = 'FAILURE'
+ }
+ }
+ }
+ stage('Stop SMO') {
+ sh './smo-install/scripts/sub-scripts/uninstall-nonrtric.sh'
+ sh './smo-install/scripts/sub-scripts/uninstall-onap.sh'
+ }
+ stage('Get Results') {
+ archiveArtifacts artifacts: 'smo-install/test/pythonsdk/src/orantests/pythonsdk.debug.log, **/reports/junit/*.xml', fingerprint: true
+ junit '**/reports/junit/*.xml'
+
+ }
+ }
+
+ }
+}
+}