1 /* Copyright ETSI Contributors and Others
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations
20 string(defaultValue: env.GERRIT_BRANCH, description: '', name: 'GERRIT_BRANCH'),
21 string(defaultValue: 'system', description: '', name: 'NODE'),
22 string(defaultValue: '', description: '', name: 'BUILD_FROM_SOURCE'),
23 string(defaultValue: 'unstable', description: '', name: 'REPO_DISTRO'),
24 string(defaultValue: '', description: '', name: 'COMMIT_ID'),
25 string(defaultValue: '-stage_2', description: '', name: 'UPSTREAM_SUFFIX'),
26 string(defaultValue: 'pubkey.asc', description: '', name: 'REPO_KEY_NAME'),
27 string(defaultValue: 'release', description: '', name: 'RELEASE'),
28 string(defaultValue: '', description: '', name: 'UPSTREAM_JOB_NAME'),
29 string(defaultValue: '', description: '', name: 'UPSTREAM_JOB_NUMBER'),
30 string(defaultValue: '', description: '', name: 'UPSTREAM_JOB_NUMBER'),
31 string(defaultValue: 'OSMETSI', description: '', name: 'GPG_KEY_NAME'),
32 string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'),
33 string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'),
34 string(defaultValue: 'testing-daily', description: '', name: 'DOCKER_TAG'),
35 string(defaultValue: 'ubuntu20.04', description: '', name: 'OPENSTACK_BASE_IMAGE'),
36 booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
37 booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'),
38 booleanParam(defaultValue: true, description: '', name: 'SAVE_ARTIFACTS_ON_SMOKE_SUCCESS'),
39 booleanParam(defaultValue: true, description: '', name: 'DO_BUILD'),
40 booleanParam(defaultValue: true, description: '', name: 'DO_INSTALL'),
41 booleanParam(defaultValue: true, description: '', name: 'DO_DOCKERPUSH'),
42 booleanParam(defaultValue: false, description: '', name: 'SAVE_ARTIFACTS_OVERRIDE'),
43 string(defaultValue: '/home/jenkins/hive/openstack-etsi.rc', description: '', name: 'HIVE_VIM_1'),
44 booleanParam(defaultValue: true, description: '', name: 'DO_ROBOT'),
45 string(defaultValue: 'sanity', description: 'sanity/regression/daily are the common options', name: 'ROBOT_TAG_NAME'),
46 string(defaultValue: '/home/jenkins/hive/robot-systest.cfg', description: '', name: 'ROBOT_VIM'),
47 string(defaultValue: '/home/jenkins/hive/port-mapping-etsi-vim.yaml', description: 'Port mapping file for SDN assist in ETSI VIM', name: 'ROBOT_PORT_MAPPING_VIM'),
48 string(defaultValue: '/home/jenkins/hive/kubeconfig.yaml', description: '', name: 'KUBECONFIG'),
49 string(defaultValue: '/home/jenkins/hive/clouds.yaml', description: '', name: 'CLOUDS'),
50 string(defaultValue: 'Default', description: '', name: 'INSTALLER'),
51 string(defaultValue: '100.0', description: '% passed Robot tests to mark the build as passed', name: 'ROBOT_PASS_THRESHOLD'),
52 string(defaultValue: '80.0', description: '% passed Robot tests to mark the build as unstable (if lower, it will be failed)', name: 'ROBOT_UNSTABLE_THRESHOLD'),
57 ////////////////////////////////////////////////////////////////////////////////////////
59 ////////////////////////////////////////////////////////////////////////////////////////
60 void run_robot_systest(String tagName,
63 String prometheusHostname,
64 Integer prometheusPort=null,
66 String portmappingfile=null,
67 String kubeconfig=null,
70 String jujuPassword=null,
71 String osmRSAfile=null,
73 String unstable_th='0.0') {
74 tempdir = sh(returnStdout: true, script: 'mktemp -d').trim()
76 sh(script: "touch ${tempdir}/env")
77 envfile="${tempdir}/env"
79 PROMETHEUS_PORT_VAR = ""
80 if ( prometheusPort != null) {
81 PROMETHEUS_PORT_VAR = "--env PROMETHEUS_PORT="+prometheusPort
85 hostfilemount="-v "+hostfile+":/etc/hosts"
88 JUJU_PASSWORD_VAR = ""
89 if ( jujuPassword != null) {
90 JUJU_PASSWORD_VAR = "--env JUJU_PASSWORD="+jujuPassword
94 sh "docker run --env OSM_HOSTNAME=${osmHostname} --env PROMETHEUS_HOSTNAME=${prometheusHostname} ${PROMETHEUS_PORT_VAR} ${JUJU_PASSWORD_VAR} --env-file ${envfile} -v ${clouds}:/etc/openstack/clouds.yaml -v ${osmRSAfile}:/root/osm_id_rsa -v ${kubeconfig}:/root/.kube/config -v ${tempdir}:/robot-systest/reports -v ${portmappingfile}:/root/port-mapping.yaml ${hostfilemount} opensourcemano/tests:${tagName} -c -t ${testName}"
96 sh "cp ${tempdir}/* ."
97 outputDirectory = sh(returnStdout: true, script: "pwd").trim()
98 println ("Present Directory is : ${outputDirectory}")
100 $class : 'RobotPublisher',
101 outputPath : "${outputDirectory}",
102 outputFileName : "*.xml",
103 disableArchiveOutput : false,
104 reportFileName : "report.html",
105 logFileName : "log.html",
106 passThreshold : pass_th,
107 unstableThreshold: unstable_th,
108 otherFiles : "*.png",
113 def archive_logs(remote) {
115 sshCommand remote: remote, command: '''mkdir -p logs'''
116 if (useCharmedInstaller) {
117 sshCommand remote: remote, command: '''
118 for container in `kubectl get pods -n osm | grep -v operator | grep -v NAME| awk '{print $1}'`; do
119 logfile=`echo $container | cut -d- -f1`
120 echo "Extracting log for $logfile"
121 kubectl logs -n osm $container --timestamps=true 2>&1 > logs/$logfile.log
125 sshCommand remote: remote, command: '''
126 for deployment in `kubectl -n osm get deployments | grep -v operator | grep -v NAME| awk '{print $1}'`; do
127 echo "Extracting log for $deployment"
128 kubectl -n osm logs deployments/$deployment --timestamps=true --all-containers 2>&1 > logs/$deployment.log
131 sshCommand remote: remote, command: '''
132 for statefulset in `kubectl -n osm get statefulsets | grep -v operator | grep -v NAME| awk '{print $1}'`; do
133 echo "Extracting log for $statefulset"
134 kubectl -n osm logs statefulsets/$statefulset --timestamps=true --all-containers 2>&1 > logs/$statefulset.log
140 sshCommand remote: remote, command: '''ls -al logs'''
141 sshGet remote: remote, from: 'logs', into: '.', override: true
143 archiveArtifacts artifacts: '*.log'
146 def get_value(key, output) {
147 for (String line : output.split( '\n' )) {
148 data = line.split( '\\|' )
149 if (data.length > 1) {
150 if ( data[1].trim() == key ) {
151 return data[2].trim()
157 ////////////////////////////////////////////////////////////////////////////////////////
159 ////////////////////////////////////////////////////////////////////////////////////////
160 node("${params.NODE}") {
162 INTERNAL_DOCKER_REGISTRY = 'osm.etsi.org:5050/devops/cicd/'
163 INTERNAL_DOCKER_PROXY = 'http://172.21.1.1:5000'
164 SSH_KEY = '~/hive/cicd_rsa'
167 tag_or_branch = params.GERRIT_BRANCH.replaceAll(/\./,"")
173 ci_helper = load "jenkins/ci-pipelines/ci_helper.groovy"
175 def upstream_main_job = params.UPSTREAM_SUFFIX
177 // upstream jobs always use merged artifacts
178 upstream_main_job += '-merge'
179 container_name_prefix = "osm-${tag_or_branch}"
180 container_name = "${container_name_prefix}"
182 keep_artifacts = false
183 if ( JOB_NAME.contains('merge') ) {
184 container_name += "-merge"
186 // On a merge job, we keep artifacts on smoke success
187 keep_artifacts = params.SAVE_ARTIFACTS_ON_SMOKE_SUCCESS
189 container_name += "-${BUILD_NUMBER}"
192 http_server_name = null
194 useCharmedInstaller = params.INSTALLER.equalsIgnoreCase("charmed")
198 ///////////////////////////////////////////////////////////////////////////////////////
199 // Fetch stage 2 .deb artifacts
200 ///////////////////////////////////////////////////////////////////////////////////////
201 stage("Copy Artifacts") {
202 // cleanup any previous repo
207 RELEASE_DIR = sh(returnStdout:true, script: 'pwd').trim()
209 // check if an upstream artifact based on specific build number has been requested
210 // This is the case of a merge build and the upstream merge build is not yet complete (it is not deemed
211 // a successful build yet). The upstream job is calling this downstream job (with the its build artifiact)
212 def upstreamComponent=""
213 if ( params.UPSTREAM_JOB_NAME ) {
214 println("Fetching upstream job artifact from ${params.UPSTREAM_JOB_NAME}")
215 lock('Artifactory') {
216 step ([$class: 'CopyArtifact',
217 projectName: "${params.UPSTREAM_JOB_NAME}",
218 selector: [$class: 'SpecificBuildSelector',
219 buildNumber: "${params.UPSTREAM_JOB_NUMBER}"]
222 upstreamComponent = ci_helper.get_mdg_from_project(
223 ci_helper.get_env_value('build.env','GERRIT_PROJECT'))
224 def buildNumber = ci_helper.get_env_value('build.env','BUILD_NUMBER')
225 dir("$upstreamComponent") {
226 // the upstream job name contains suffix with the project. Need this stripped off
227 def project_without_branch = params.UPSTREAM_JOB_NAME.split('/')[0]
228 def packages = ci_helper.get_archive(params.ARTIFACTORY_SERVER,
231 "${project_without_branch} :: ${GERRIT_BRANCH}",
234 packageList.addAll(packages)
235 println("Fetched pre-merge ${params.UPSTREAM_JOB_NAME}: ${packages}")
237 } // lock artifactory
241 def list = ["RO", "osmclient", "IM", "devops", "MON", "N2VC", "NBI", "common", "LCM", "POL", "NG-UI", "PLA", "tests"]
242 if (upstreamComponent.length()>0) {
243 println("Skipping upstream fetch of "+upstreamComponent)
244 list.remove(upstreamComponent)
246 for (buildStep in list) {
247 def component = buildStep
248 parallelSteps[component] = {
250 println("Fetching artifact for ${component}")
251 step ([$class: 'CopyArtifact',
252 projectName: "${component}${upstream_main_job}/${GERRIT_BRANCH}"])
254 // grab the archives from the stage_2 builds (ie. this will be the artifacts stored based on a merge)
255 def packages = ci_helper.get_archive(params.ARTIFACTORY_SERVER,
258 "${component}${upstream_main_job} :: ${GERRIT_BRANCH}",
259 ci_helper.get_env_value('build.env','BUILD_NUMBER'))
260 packageList.addAll(packages)
261 println("Fetched ${component}: ${packages}")
266 lock('Artifactory') {
267 parallel parallelSteps
270 ///////////////////////////////////////////////////////////////////////////////////////
271 // Create Devops APT repository
272 ///////////////////////////////////////////////////////////////////////////////////////
274 for (component in [ "devops", "IM", "osmclient" ]) {
275 sh "ls -al ${component}/pool/"
276 sh "cp -r ${component}/pool/* pool/"
277 sh "dpkg-sig --sign builder -k ${GPG_KEY_NAME} pool/${component}/*"
278 sh "mkdir -p dists/${params.REPO_DISTRO}/${component}/binary-amd64/"
279 sh "apt-ftparchive packages pool/${component} > dists/${params.REPO_DISTRO}/${component}/binary-amd64/Packages"
280 sh "gzip -9fk dists/${params.REPO_DISTRO}/${component}/binary-amd64/Packages"
283 // create and sign the release file
284 sh "apt-ftparchive release dists/${params.REPO_DISTRO} > dists/${params.REPO_DISTRO}/Release"
285 sh "gpg --yes -abs -u ${GPG_KEY_NAME} -o dists/${params.REPO_DISTRO}/Release.gpg dists/${params.REPO_DISTRO}/Release"
287 // copy the public key into the release folder
288 // this pulls the key from the home dir of the current user (jenkins)
289 sh "cp ~/${REPO_KEY_NAME} 'OSM ETSI Release Key.gpg'"
290 sh "cp ~/${REPO_KEY_NAME} ."
293 // start an apache server to serve up the packages
294 http_server_name = "${container_name}-apache"
296 pwd = sh(returnStdout:true, script: 'pwd').trim()
297 repo_port = sh(script: 'echo $(python -c \'import socket; s=socket.socket(); s.bind(("", 0));' +
298 'print(s.getsockname()[1]); s.close()\');',
299 returnStdout: true).trim()
300 internal_docker_http_server_url = ci_helper.start_http_server(pwd, http_server_name, repo_port)
301 NODE_IP_ADDRESS = sh(returnStdout: true, script:
302 "echo ${SSH_CONNECTION} | awk '{print \$3}'").trim()
303 ci_helper.check_status_http_server(NODE_IP_ADDRESS, repo_port)
306 // Unpack devops package into temporary location so that we use it from upstream if it was part of a patch
307 osm_devops_dpkg = sh(returnStdout: true, script: "find ./repo/release/pool/ -name osm-devops*.deb").trim()
308 devopstempdir = sh(returnStdout: true, script: "mktemp -d").trim()
309 println("Extracting local devops package ${osm_devops_dpkg} into ${devopstempdir} for docker build step")
310 sh "dpkg -x ${osm_devops_dpkg} ${devopstempdir}"
311 OSM_DEVOPS="${devopstempdir}/usr/share/osm-devops"
312 // Convert URLs from stage 2 packages to arguments that can be passed to docker build
313 for (remotePath in packageList) {
314 packageName=remotePath.substring(remotePath.lastIndexOf('/')+1)
315 packageName=packageName.substring(0,packageName.indexOf('_'))
316 builtModules[packageName]=remotePath
320 ///////////////////////////////////////////////////////////////////////////////////////
321 // Build docker containers
322 ///////////////////////////////////////////////////////////////////////////////////////
326 if ( params.DO_BUILD ) {
327 withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry',
328 usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
329 sh "docker login ${INTERNAL_DOCKER_REGISTRY} -u ${USERNAME} -p ${PASSWORD}"
332 for (packageName in builtModules.keySet()) {
333 envName=packageName.replaceAll("-","_").toUpperCase()+"_URL"
334 moduleBuildArgs += " --build-arg ${envName}=" + builtModules[packageName]
338 containerList = sh(returnStdout: true, script:
339 "find . -name Dockerfile -printf '%h\\n' | sed 's|\\./||'")
340 containerList=Arrays.asList(containerList.split("\n"))
343 for (buildStep in containerList) {
344 def module = buildStep
345 def moduleName = buildStep.toLowerCase()
346 def moduleTag = container_name
347 parallelSteps[module] = {
349 sh "docker build -t opensourcemano/${moduleName}:${moduleTag} ${moduleBuildArgs} ."
350 println("Tagging ${moduleName}:${moduleTag}")
351 sh "docker tag opensourcemano/${moduleName}:${moduleTag} ${INTERNAL_DOCKER_REGISTRY}opensourcemano/${moduleName}:${moduleTag}"
352 sh "docker push ${INTERNAL_DOCKER_REGISTRY}opensourcemano/${moduleName}:${moduleTag}"
356 parallel parallelSteps
359 } // if ( params.DO_BUILD )
361 if ( params.DO_INSTALL ) {
362 ///////////////////////////////////////////////////////////////////////////////////////
364 ///////////////////////////////////////////////////////////////////////////////////////
365 stage("Spawn Remote VM") {
366 println("Launching new VM")
367 output=sh(returnStdout: true, script: """#!/bin/sh -e
368 for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done
369 openstack server create --flavor osm.sanity \
370 --image ${OPENSTACK_BASE_IMAGE} \
372 --property build_url="${BUILD_URL}" \
373 --nic net-id=osm-ext \
377 server_id = get_value('id', output)
379 if (server_id == null) {
380 println("VM launch output: ")
382 throw new Exception("VM Launch failed")
384 println("Target VM is ${server_id}, waiting for IP address to be assigned")
388 while (IP_ADDRESS == "") {
389 output=sh(returnStdout: true, script: """#!/bin/sh -e
390 for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done
391 openstack server show ${server_id}
393 IP_ADDRESS = get_value('addresses', output)
395 IP_ADDRESS = IP_ADDRESS.split('=')[1]
396 println("Waiting for VM at ${IP_ADDRESS} to be reachable")
399 timeout(time: 1, unit: 'MINUTES') {
403 script: "ssh -T -i ${SSH_KEY} " +
404 "-o StrictHostKeyChecking=no " +
405 "-o UserKnownHostsFile=/dev/null " +
406 "-o ConnectTimeout=5 ubuntu@${IP_ADDRESS} 'echo Alive'")
407 alive = (output == 0)
410 println("VM is ready and accepting ssh connections")
411 } // stage("Spawn Remote VM")
413 ///////////////////////////////////////////////////////////////////////////////////////
415 ///////////////////////////////////////////////////////////////////////////////////////
422 if ( params.COMMIT_ID )
424 commit_id = "-b ${params.COMMIT_ID}"
427 if ( params.REPO_DISTRO )
429 repo_distro = "-r ${params.REPO_DISTRO}"
432 if ( params.REPO_KEY_NAME )
434 repo_key_name = "-k ${params.REPO_KEY_NAME}"
437 if ( params.RELEASE )
439 release = "-R ${params.RELEASE}"
442 if ( params.REPOSITORY_BASE )
444 repo_base_url = "-u ${params.REPOSITORY_BASE}"
448 repo_base_url = "-u http://${NODE_IP_ADDRESS}:${repo_port}"
451 remote.name = container_name
452 remote.host = IP_ADDRESS
453 remote.user = 'ubuntu'
454 remote.identityFile = SSH_KEY
455 remote.allowAnyHosts = true
456 remote.logLevel = 'INFO'
459 // Ensure the VM is ready
460 sshCommand remote: remote, command: 'cloud-init status --wait'
462 // Force time sync to avoid clock drift and invalid certificates
463 sshCommand remote: remote, command: """
465 sudo apt install -y chrony
466 sudo service chrony stop
468 sudo service chrony start
471 sshCommand remote: remote, command: """
472 wget https://osm-download.etsi.org/ftp/osm-10.0-ten/install_osm.sh
473 chmod +x ./install_osm.sh
474 sed -i '1 i\\export PATH=/snap/bin:\${PATH}' ~/.bashrc
477 if ( useCharmedInstaller ) {
478 // Use local proxy for docker hub
479 sshCommand remote: remote, command: '''
480 sudo snap install microk8s --classic --channel=1.19/stable
481 sudo sed -i "s|https://registry-1.docker.io|http://172.21.1.1:5000|" /var/snap/microk8s/current/args/containerd-template.toml
482 sudo systemctl restart snap.microk8s.daemon-containerd.service
483 sudo snap alias microk8s.kubectl kubectl
486 withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry',
487 usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
488 sshCommand remote: remote, command: """
489 ./install_osm.sh -y \
492 ${release} -r unstable \
494 --registry ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \
495 --tag ${container_name}
498 prometheusHostname = "prometheus."+IP_ADDRESS+".nip.io"
500 osmHostname = "nbi."+IP_ADDRESS+".nip.io:443"
502 // Run -k8s installer here specifying internal docker registry and docker proxy
503 withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry',
504 usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
505 sshCommand remote: remote, command: """
506 ./install_osm.sh -y \
509 ${release} -r unstable \
510 -d ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \
511 -p ${INTERNAL_DOCKER_PROXY} \
512 -t ${container_name} \
516 prometheusHostname = IP_ADDRESS
517 prometheusPort = 9091
518 osmHostname = IP_ADDRESS
520 } // stage("Install")
521 ///////////////////////////////////////////////////////////////////////////////////////
522 // Health check of installed OSM in remote vm
523 ///////////////////////////////////////////////////////////////////////////////////////
524 stage("OSM Health") {
526 sshCommand remote: remote, command: """
527 /usr/share/osm-devops/installers/osm_health.sh -k -s ${stackName}
529 } // stage("OSM Health")
530 } // if ( params.DO_INSTALL )
533 ///////////////////////////////////////////////////////////////////////////////////////
534 // Execute Robot tests
535 ///////////////////////////////////////////////////////////////////////////////////////
536 stage_archive = false
537 if ( params.DO_ROBOT ) {
539 stage("System Integration Test") {
540 if ( useCharmedInstaller ) {
541 tempdir = sh(returnStdout: true, script: "mktemp -d").trim()
542 sh(script: "touch ${tempdir}/hosts")
543 hostfile="${tempdir}/hosts"
544 sh """cat << EOF > ${hostfile}
546 ${remote.host} prometheus.${remote.host}.nip.io nbi.${remote.host}.nip.io
552 jujuPassword=sshCommand remote: remote, command: """
553 echo `juju gui 2>&1 | grep password | cut -d: -f2`
558 params.ROBOT_TAG_NAME,
563 params.ROBOT_PORT_MAPPING_VIM,
569 params.ROBOT_PASS_THRESHOLD,
570 params.ROBOT_UNSTABLE_THRESHOLD
572 } // stage("System Integration Test")
574 stage("Archive Container Logs") {
575 // Archive logs to containers_logs.txt
577 if ( ! currentBuild.result.equals('FAILURE') ) {
578 stage_archive = keep_artifacts
580 println ("Systest test failed, throwing error")
581 error = new Exception("Systest test failed")
582 currentBuild.result = 'FAILURE'
587 } // if ( params.DO_ROBOT )
589 if ( params.SAVE_ARTIFACTS_OVERRIDE || stage_archive ) {
591 sh "echo ${container_name} > build_version.txt"
592 archiveArtifacts artifacts: "build_version.txt", fingerprint: true
594 // Archive the tested repo
595 dir("${RELEASE_DIR}") {
596 ci_helper.archive(params.ARTIFACTORY_SERVER,RELEASE,GERRIT_BRANCH,'tested')
598 if ( params.DO_DOCKERPUSH ) {
599 stage("Publish to Dockerhub") {
601 for (buildStep in containerList) {
602 def module = buildStep
603 def moduleName = buildStep.toLowerCase()
604 def dockerTag = params.DOCKER_TAG
605 def moduleTag = container_name
607 parallelSteps[module] = {
609 sh "docker tag opensourcemano/${moduleName}:${moduleTag} opensourcemano/${moduleName}:${dockerTag}"
610 sh "docker push opensourcemano/${moduleName}:${dockerTag}"
614 parallel parallelSteps
617 stage('Snap promotion') {
618 withCredentials([string(credentialsId: 'Snapstore', variable: 'SNAPCRAFT_STORE_CREDENTIALS')]) {
619 snaps = ['osmclient']
620 for (snap in snaps) {
622 if (BRANCH_NAME.startsWith('v')) {
623 channel = BRANCH_NAME.substring(1) + '/'
624 } else if (BRANCH_NAME != 'master') {
625 channel += '/' + BRANCH_NAME.replaceAll('/', '-')
627 track = channel + 'edge\\*'
628 edge_rev = sh(returnStdout: true,
629 script: "snapcraft revisions $snap | " +
630 "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
631 print "edge rev is $edge_rev"
632 track = channel + 'beta\\*'
633 beta_rev = sh(returnStdout: true,
634 script: "snapcraft revisions $snap | " +
635 "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
636 print "beta rev is $beta_rev"
638 if (edge_rev != beta_rev) {
639 print "Promoting $edge_rev to beta in place of $beta_rev"
640 beta_track = channel + 'beta'
641 sh "snapcraft release $snap $edge_rev $beta_track"
645 } // stage("Snap promotion")
646 } // if ( params.DO_DOCKERPUSH )
647 } // stage("Archive")
648 } // if ( params.SAVE_ARTIFACTS_OVERRIDE || stage_archive )
651 if ( params.DO_INSTALL && server_id != null) {
653 if (error && params.SAVE_CONTAINER_ON_FAIL ) {
656 if (!error && params.SAVE_CONTAINER_ON_PASS ) {
661 if (server_id != null) {
662 println("Deleting VM: $server_id")
664 for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done
665 openstack server delete ${server_id}
668 println("Saved VM $server_id in ETSI VIM")
672 if ( http_server_name != null ) {
673 sh "docker stop ${http_server_name} || true"
674 sh "docker rm ${http_server_name} || true"
677 if ( devopstempdir != null ) {
678 sh "rm -rf ${devopstempdir}"