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: 'OSMETSI', description: '', name: 'GPG_KEY_NAME'),
31 string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'),
32 string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'),
33 string(defaultValue: 'testing-daily', description: '', name: 'DOCKER_TAG'),
34 string(defaultValue: 'ubuntu20.04', description: '', name: 'OPENSTACK_BASE_IMAGE'),
35 booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
36 booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'),
37 booleanParam(defaultValue: true, description: '', name: 'SAVE_ARTIFACTS_ON_SMOKE_SUCCESS'),
38 booleanParam(defaultValue: true, description: '', name: 'DO_BUILD'),
39 booleanParam(defaultValue: true, description: '', name: 'DO_INSTALL'),
40 booleanParam(defaultValue: true, description: '', name: 'DO_DOCKERPUSH'),
41 booleanParam(defaultValue: false, description: '', name: 'SAVE_ARTIFACTS_OVERRIDE'),
42 string(defaultValue: '/home/jenkins/hive/openstack-etsi.rc', description: '', name: 'HIVE_VIM_1'),
43 booleanParam(defaultValue: true, description: '', name: 'DO_ROBOT'),
44 string(defaultValue: 'sanity', description: 'sanity/regression/daily are the common options',
45 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',
48 description: 'Port mapping file for SDN assist in ETSI VIM',
49 name: 'ROBOT_PORT_MAPPING_VIM'),
50 string(defaultValue: '/home/jenkins/hive/kubeconfig.yaml', description: '', name: 'KUBECONFIG'),
51 string(defaultValue: '/home/jenkins/hive/clouds.yaml', description: '', name: 'CLOUDS'),
52 string(defaultValue: 'Default', description: '', name: 'INSTALLER'),
53 string(defaultValue: '100.0', description: '% passed Robot tests to mark the build as passed',
54 name: 'ROBOT_PASS_THRESHOLD'),
55 string(defaultValue: '80.0', description: '% passed Robot tests to mark the build as unstable ' +
56 '(if lower, it will be failed)', name: 'ROBOT_UNSTABLE_THRESHOLD'),
60 ////////////////////////////////////////////////////////////////////////////////////////
62 ////////////////////////////////////////////////////////////////////////////////////////
63 void run_robot_systest(String tagName,
66 String prometheusHostname,
67 Integer prometheusPort=null,
69 String portmappingfile=null,
70 String kubeconfig=null,
73 String jujuPassword=null,
74 String osmRSAfile=null,
75 String passThreshold='0.0',
76 String unstableThreshold='0.0') {
77 tempdir = sh(returnStdout: true, script: 'mktemp -d').trim()
78 String environmentFile = ''
80 environmentFile = envfile
82 sh(script: "touch ${tempdir}/env")
83 environmentFile = "${tempdir}/env"
85 PROMETHEUS_PORT_VAR = ''
86 if (prometheusPort != null) {
87 PROMETHEUS_PORT_VAR = "--env PROMETHEUS_PORT=${prometheusPort}"
91 hostfilemount = "-v ${hostfile}:/etc/hosts"
94 JUJU_PASSWORD_VAR = ''
95 if (jujuPassword != null) {
96 JUJU_PASSWORD_VAR = "--env JUJU_PASSWORD=${jujuPassword}"
100 sh("""docker run --env OSM_HOSTNAME=${osmHostname} --env PROMETHEUS_HOSTNAME=${prometheusHostname} \
101 ${PROMETHEUS_PORT_VAR} ${JUJU_PASSWORD_VAR} --env-file ${environmentFile} \
102 -v ${clouds}:/etc/openstack/clouds.yaml \
103 -v ${osmRSAfile}:/root/osm_id_rsa -v ${kubeconfig}:/root/.kube/config -v ${tempdir}:/robot-systest/reports \
104 -v ${portmappingfile}:/root/port-mapping.yaml ${hostfilemount} opensourcemano/tests:${tagName} \
105 -c -t ${testName}""")
107 sh("cp ${tempdir}/* .")
108 outputDirectory = sh(returnStdout: true, script: 'pwd').trim()
109 println("Present Directory is : ${outputDirectory}")
111 $class : 'RobotPublisher',
112 outputPath : "${outputDirectory}",
113 outputFileName : '*.xml',
114 disableArchiveOutput : false,
115 reportFileName : 'report.html',
116 logFileName : 'log.html',
117 passThreshold : passThreshold,
118 unstableThreshold: unstableThreshold,
119 otherFiles : '*.png',
124 void archive_logs(Map remote) {
126 sshCommand remote: remote, command: '''mkdir -p logs'''
127 if (useCharmedInstaller) {
128 sshCommand remote: remote, command: '''
129 for container in `kubectl get pods -n osm | grep -v operator | grep -v NAME| awk '{print $1}'`; do
130 logfile=`echo $container | cut -d- -f1`
131 echo "Extracting log for $logfile"
132 kubectl logs -n osm $container --timestamps=true 2>&1 > logs/$logfile.log
136 sshCommand remote: remote, command: '''
137 for deployment in `kubectl -n osm get deployments | grep -v operator | grep -v NAME| awk '{print $1}'`; do
138 echo "Extracting log for $deployment"
139 kubectl -n osm logs deployments/$deployment --timestamps=true --all-containers 2>&1 \
140 > logs/$deployment.log
143 sshCommand remote: remote, command: '''
144 for statefulset in `kubectl -n osm get statefulsets | grep -v operator | grep -v NAME| awk '{print $1}'`; do
145 echo "Extracting log for $statefulset"
146 kubectl -n osm logs statefulsets/$statefulset --timestamps=true --all-containers 2>&1 \
147 > logs/$statefulset.log
153 sshCommand remote: remote, command: '''ls -al logs'''
154 sshGet remote: remote, from: 'logs', into: '.', override: true
156 archiveArtifacts artifacts: '*.log'
159 String get_value(String key, String output) {
160 for (String line : output.split( '\n' )) {
161 data = line.split( '\\|' )
162 if (data.length > 1) {
163 if ( data[1].trim() == key ) {
164 return data[2].trim()
170 ////////////////////////////////////////////////////////////////////////////////////////
172 ////////////////////////////////////////////////////////////////////////////////////////
173 node("${params.NODE}") {
175 INTERNAL_DOCKER_REGISTRY = 'osm.etsi.org:5050/devops/cicd/'
176 INTERNAL_DOCKER_PROXY = 'http://172.21.1.1:5000'
177 APT_PROXY = 'http://172.21.1.1:3142'
178 SSH_KEY = '~/hive/cicd_rsa'
181 tag_or_branch = params.GERRIT_BRANCH.replaceAll(/\./, '')
187 ci_helper = load 'jenkins/ci-pipelines/ci_helper.groovy'
189 def upstreamMainJob = params.UPSTREAM_SUFFIX
191 // upstream jobs always use merged artifacts
192 upstreamMainJob += '-merge'
193 containerNamePrefix = "osm-${tag_or_branch}"
194 containerName = "${containerNamePrefix}"
196 keep_artifacts = false
197 if ( JOB_NAME.contains('merge') ) {
198 containerName += '-merge'
200 // On a merge job, we keep artifacts on smoke success
201 keep_artifacts = params.SAVE_ARTIFACTS_ON_SMOKE_SUCCESS
203 containerName += "-${BUILD_NUMBER}"
206 http_server_name = null
208 useCharmedInstaller = params.INSTALLER.equalsIgnoreCase('charmed')
212 ///////////////////////////////////////////////////////////////////////////////////////
213 // Fetch stage 2 .deb artifacts
214 ///////////////////////////////////////////////////////////////////////////////////////
215 stage('Copy Artifacts') {
216 // cleanup any previous repo
221 RELEASE_DIR = sh(returnStdout:true, script: 'pwd').trim()
223 // check if an upstream artifact based on specific build number has been requested
224 // This is the case of a merge build and the upstream merge build is not yet complete
225 // (it is not deemed a successful build yet). The upstream job is calling this downstream
226 // job (with the its build artifact)
227 def upstreamComponent = ''
228 if (params.UPSTREAM_JOB_NAME) {
229 println("Fetching upstream job artifact from ${params.UPSTREAM_JOB_NAME}")
230 lock('Artifactory') {
231 step ([$class: 'CopyArtifact',
232 projectName: "${params.UPSTREAM_JOB_NAME}",
233 selector: [$class: 'SpecificBuildSelector',
234 buildNumber: "${params.UPSTREAM_JOB_NUMBER}"]
237 upstreamComponent = ci_helper.get_mdg_from_project(
238 ci_helper.get_env_value('build.env','GERRIT_PROJECT'))
239 def buildNumber = ci_helper.get_env_value('build.env','BUILD_NUMBER')
240 dir("$upstreamComponent") {
241 // the upstream job name contains suffix with the project. Need this stripped off
242 project_without_branch = params.UPSTREAM_JOB_NAME.split('/')[0]
243 packages = ci_helper.get_archive(params.ARTIFACTORY_SERVER,
246 "${project_without_branch} :: ${GERRIT_BRANCH}",
249 packageList.addAll(packages)
250 println("Fetched pre-merge ${params.UPSTREAM_JOB_NAME}: ${packages}")
252 } // lock artifactory
256 list = ['RO', 'osmclient', 'IM', 'devops', 'MON', 'N2VC', 'NBI',
257 'common', 'LCM', 'POL', 'NG-UI', 'PLA', 'tests']
258 if (upstreamComponent.length() > 0) {
259 println("Skipping upstream fetch of ${upstreamComponent}")
260 list.remove(upstreamComponent)
262 for (buildStep in list) {
263 def component = buildStep
264 parallelSteps[component] = {
266 println("Fetching artifact for ${component}")
267 step([$class: 'CopyArtifact',
268 projectName: "${component}${upstreamMainJob}/${GERRIT_BRANCH}"])
270 // grab the archives from the stage_2 builds
271 // (ie. this will be the artifacts stored based on a merge)
272 packages = ci_helper.get_archive(params.ARTIFACTORY_SERVER,
275 "${component}${upstreamMainJob} :: ${GERRIT_BRANCH}",
276 ci_helper.get_env_value('build.env', 'BUILD_NUMBER'))
277 packageList.addAll(packages)
278 println("Fetched ${component}: ${packages}")
283 lock('Artifactory') {
284 parallel parallelSteps
287 ///////////////////////////////////////////////////////////////////////////////////////
288 // Create Devops APT repository
289 ///////////////////////////////////////////////////////////////////////////////////////
291 for (component in [ 'devops', 'IM', 'osmclient' ]) {
292 sh "ls -al ${component}/pool/"
293 sh "cp -r ${component}/pool/* pool/"
294 sh "dpkg-sig --sign builder -k ${GPG_KEY_NAME} pool/${component}/*"
295 sh "mkdir -p dists/${params.REPO_DISTRO}/${component}/binary-amd64/"
296 sh("""apt-ftparchive packages pool/${component} \
297 > dists/${params.REPO_DISTRO}/${component}/binary-amd64/Packages""")
298 sh "gzip -9fk dists/${params.REPO_DISTRO}/${component}/binary-amd64/Packages"
301 // create and sign the release file
302 sh "apt-ftparchive release dists/${params.REPO_DISTRO} > dists/${params.REPO_DISTRO}/Release"
303 sh("""gpg --yes -abs -u ${GPG_KEY_NAME} \
304 -o dists/${params.REPO_DISTRO}/Release.gpg dists/${params.REPO_DISTRO}/Release""")
306 // copy the public key into the release folder
307 // this pulls the key from the home dir of the current user (jenkins)
308 sh "cp ~/${REPO_KEY_NAME} 'OSM ETSI Release Key.gpg'"
309 sh "cp ~/${REPO_KEY_NAME} ."
312 // start an apache server to serve up the packages
313 http_server_name = "${containerName}-apache"
315 pwd = sh(returnStdout:true, script: 'pwd').trim()
316 repo_port = sh(script: 'echo $(python -c \'import socket; s=socket.socket(); s.bind(("", 0));' +
317 'print(s.getsockname()[1]); s.close()\');',
318 returnStdout: true).trim()
319 repo_base_url = ci_helper.start_http_server(pwd, http_server_name, repo_port)
320 NODE_IP_ADDRESS = sh(returnStdout: true, script:
321 "echo ${SSH_CONNECTION} | awk '{print \$3}'").trim()
324 // Unpack devops package into temporary location so that we use it from upstream if it was part of a patch
325 osm_devops_dpkg = sh(returnStdout: true, script: 'find ./repo/release/pool/ -name osm-devops*.deb').trim()
326 devopstempdir = sh(returnStdout: true, script: 'mktemp -d').trim()
327 println("Extracting local devops package ${osm_devops_dpkg} into ${devopstempdir} for docker build step")
328 sh "dpkg -x ${osm_devops_dpkg} ${devopstempdir}"
329 OSM_DEVOPS = "${devopstempdir}/usr/share/osm-devops"
330 // Convert URLs from stage 2 packages to arguments that can be passed to docker build
331 for (remotePath in packageList) {
332 packageName = remotePath[remotePath.lastIndexOf('/') + 1 .. -1]
333 packageName = packageName[0 .. packageName.indexOf('_') - 1]
334 builtModules[packageName] = remotePath
338 ///////////////////////////////////////////////////////////////////////////////////////
339 // Build docker containers
340 ///////////////////////////////////////////////////////////////////////////////////////
344 if ( params.DO_BUILD ) {
345 withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry',
346 usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
347 sh "docker login ${INTERNAL_DOCKER_REGISTRY} -u ${USERNAME} -p ${PASSWORD}"
349 datetime = sh(returnStdout: true, script: 'date +%Y-%m-%d:%H:%M:%S').trim()
350 moduleBuildArgs = " --build-arg CACHE_DATE=${datetime}"
351 for (packageName in builtModules.keySet()) {
352 envName = packageName.replaceAll('-', '_').toUpperCase() + '_URL'
353 moduleBuildArgs += " --build-arg ${envName}=" + builtModules[packageName]
357 containerList = sh(returnStdout: true, script:
358 "find . -name Dockerfile -printf '%h\\n' | sed 's|\\./||'")
359 containerList = Arrays.asList(containerList.split('\n'))
362 for (buildStep in containerList) {
363 def module = buildStep
364 def moduleName = buildStep.toLowerCase()
365 def moduleTag = containerName
366 parallelSteps[module] = {
368 sh("""docker build --build-arg APT_PROXY=${APT_PROXY} \
369 -t opensourcemano/${moduleName}:${moduleTag} ${moduleBuildArgs} .""")
370 println("Tagging ${moduleName}:${moduleTag}")
371 sh("""docker tag opensourcemano/${moduleName}:${moduleTag} \
372 ${INTERNAL_DOCKER_REGISTRY}opensourcemano/${moduleName}:${moduleTag}""")
374 ${INTERNAL_DOCKER_REGISTRY}opensourcemano/${moduleName}:${moduleTag}""")
378 parallel parallelSteps
381 } // if (params.DO_BUILD)
383 if (params.DO_INSTALL) {
384 ///////////////////////////////////////////////////////////////////////////////////////
386 ///////////////////////////////////////////////////////////////////////////////////////
387 stage('Spawn Remote VM') {
388 println('Launching new VM')
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 create --flavor osm.sanity \
392 --image ${OPENSTACK_BASE_IMAGE} \
394 --property build_url="${BUILD_URL}" \
395 --nic net-id=osm-ext \
399 server_id = get_value('id', output)
401 if (server_id == null) {
402 println('VM launch output: ')
404 throw new Exception('VM Launch failed')
406 println("Target VM is ${server_id}, waiting for IP address to be assigned")
410 while (IP_ADDRESS == '') {
411 output = sh(returnStdout: true, script: """#!/bin/sh -e
412 for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done
413 openstack server show ${server_id}
415 IP_ADDRESS = get_value('addresses', output)
417 IP_ADDRESS = IP_ADDRESS.split('=')[1]
418 println("Waiting for VM at ${IP_ADDRESS} to be reachable")
421 timeout(time: 1, unit: 'MINUTES') {
425 script: "ssh -T -i ${SSH_KEY} " +
426 "-o StrictHostKeyChecking=no " +
427 "-o UserKnownHostsFile=/dev/null " +
428 "-o ConnectTimeout=5 ubuntu@${IP_ADDRESS} 'echo Alive'")
429 alive = (output == 0)
432 println('VM is ready and accepting ssh connections')
433 } // stage("Spawn Remote VM")
435 ///////////////////////////////////////////////////////////////////////////////////////
436 // Checks before installation
437 ///////////////////////////////////////////////////////////////////////////////////////
438 stage('Checks before installation') {
443 identityFile: SSH_KEY,
449 // Force time sync to avoid clock drift and invalid certificates
450 sshCommand remote: remote, command: 'sudo apt-get update'
451 sshCommand remote: remote, command: 'sudo apt-get install -y chrony'
452 sshCommand remote: remote, command: 'sudo service chrony stop'
453 sshCommand remote: remote, command: 'sudo chronyd -vq'
454 sshCommand remote: remote, command: 'sudo service chrony start'
456 } // stage("Checks before installation")
457 ///////////////////////////////////////////////////////////////////////////////////////
459 ///////////////////////////////////////////////////////////////////////////////////////
466 if (params.COMMIT_ID) {
467 commit_id = "-b ${params.COMMIT_ID}"
469 if (params.REPO_DISTRO) {
470 repo_distro = "-r ${params.REPO_DISTRO}"
472 if (params.REPO_KEY_NAME) {
473 repo_key_name = "-k ${params.REPO_KEY_NAME}"
475 if (params.RELEASE) {
476 release = "-R ${params.RELEASE}"
478 if (params.REPOSITORY_BASE) {
479 repo_base_url = "-u ${params.REPOSITORY_BASE}"
481 repo_base_url = "-u http://${NODE_IP_ADDRESS}:${repo_port}"
488 identityFile: SSH_KEY,
494 sshCommand remote: remote, command: '''
495 wget https://osm-download.etsi.org/ftp/osm-11.0-eleven/install_osm.sh
496 chmod +x ./install_osm.sh
497 sed -i '1 i\\export PATH=/snap/bin:\$PATH' ~/.bashrc
500 Map gitlabCredentialsMap = [$class: 'UsernamePasswordMultiBinding',
501 credentialsId: 'gitlab-registry',
502 usernameVariable: 'USERNAME',
503 passwordVariable: 'PASSWORD']
504 if (useCharmedInstaller) {
505 // Use local proxy for docker hub
506 sshCommand remote: remote, command: '''
507 sudo snap install microk8s --classic --channel=1.19/stable
508 sudo sed -i "s|https://registry-1.docker.io|http://172.21.1.1:5000|" \
509 /var/snap/microk8s/current/args/containerd-template.toml
510 sudo systemctl restart snap.microk8s.daemon-containerd.service
511 sudo snap alias microk8s.kubectl kubectl
514 withCredentials([gitlabCredentialsMap]) {
515 sshCommand remote: remote, command: """
516 ./install_osm.sh -y \
519 ${release} -r unstable \
521 --registry ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \
522 --tag ${containerName}
525 prometheusHostname = "prometheus.${IP_ADDRESS}.nip.io"
527 osmHostname = "nbi.${IP_ADDRESS}.nip.io:443"
529 // Run -k8s installer here specifying internal docker registry and docker proxy
530 withCredentials([gitlabCredentialsMap]) {
531 sshCommand remote: remote, command: """
532 ./install_osm.sh -y \
535 ${release} -r unstable \
536 -d ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \
537 -p ${INTERNAL_DOCKER_PROXY} \
541 prometheusHostname = IP_ADDRESS
542 prometheusPort = 9091
543 osmHostname = IP_ADDRESS
545 } // stage("Install")
546 ///////////////////////////////////////////////////////////////////////////////////////
547 // Health check of installed OSM in remote vm
548 ///////////////////////////////////////////////////////////////////////////////////////
549 stage('OSM Health') {
551 sshCommand remote: remote, command: """
552 /usr/share/osm-devops/installers/osm_health.sh -k -s ${stackName}
554 } // stage("OSM Health")
555 } // if ( params.DO_INSTALL )
558 ///////////////////////////////////////////////////////////////////////////////////////
559 // Execute Robot tests
560 ///////////////////////////////////////////////////////////////////////////////////////
561 stage_archive = false
562 if ( params.DO_ROBOT ) {
564 stage('System Integration Test') {
565 if (useCharmedInstaller) {
566 tempdir = sh(returnStdout: true, script: 'mktemp -d').trim()
567 sh(script: "touch ${tempdir}/hosts")
568 hostfile = "${tempdir}/hosts"
569 sh """cat << EOF > ${hostfile}
571 ${remote.host} prometheus.${remote.host}.nip.io nbi.${remote.host}.nip.io
577 jujuPassword = sshCommand remote: remote, command: '''
578 echo `juju gui 2>&1 | grep password | cut -d: -f2`
583 params.ROBOT_TAG_NAME,
588 params.ROBOT_PORT_MAPPING_VIM,
594 params.ROBOT_PASS_THRESHOLD,
595 params.ROBOT_UNSTABLE_THRESHOLD
597 } // stage("System Integration Test")
599 stage('Archive Container Logs') {
600 // Archive logs to containers_logs.txt
602 if (currentBuild.result != 'FAILURE') {
603 stage_archive = keep_artifacts
605 println('Systest test failed, throwing error')
606 error = new Exception('Systest test failed')
607 currentBuild.result = 'FAILURE'
612 } // if ( params.DO_ROBOT )
614 if (params.SAVE_ARTIFACTS_OVERRIDE || stage_archive) {
616 sh "echo ${containerName} > build_version.txt"
617 archiveArtifacts artifacts: 'build_version.txt', fingerprint: true
619 // Archive the tested repo
620 dir("${RELEASE_DIR}") {
621 ci_helper.archive(params.ARTIFACTORY_SERVER, RELEASE, GERRIT_BRANCH, 'tested')
623 if (params.DO_DOCKERPUSH) {
624 stage('Publish to Dockerhub') {
626 for (buildStep in containerList) {
627 def module = buildStep
628 def moduleName = buildStep.toLowerCase()
629 def dockerTag = params.DOCKER_TAG
630 def moduleTag = containerName
632 parallelSteps[module] = {
634 sh("""docker tag opensourcemano/${moduleName}:${moduleTag} \
635 opensourcemano/${moduleName}:${dockerTag}""")
636 sh "docker push opensourcemano/${moduleName}:${dockerTag}"
640 parallel parallelSteps
643 stage('Snap promotion') {
644 snaps = ['osmclient']
645 sh 'snapcraft login --with ~/.snapcraft/config'
646 for (snap in snaps) {
648 if (BRANCH_NAME.startsWith('v')) {
649 channel = BRANCH_NAME.substring(1) + '/'
650 } else if (BRANCH_NAME != 'master') {
651 channel += '/' + BRANCH_NAME.replaceAll('/', '-')
653 track = channel + 'edge\\*'
654 edge_rev = sh(returnStdout: true,
655 script: "snapcraft revisions $snap | " +
656 "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
657 print "edge rev is $edge_rev"
658 track = channel + 'beta\\*'
659 beta_rev = sh(returnStdout: true,
660 script: "snapcraft revisions $snap | " +
661 "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
662 print "beta rev is $beta_rev"
664 if (edge_rev != beta_rev) {
665 print "Promoting $edge_rev to beta in place of $beta_rev"
666 beta_track = channel + 'beta'
667 sh "snapcraft release $snap $edge_rev $beta_track"
670 } // stage('Snap promotion')
671 } // if (params.DO_DOCKERPUSH)
672 } // stage('Archive')
673 } // if (params.SAVE_ARTIFACTS_OVERRIDE || stage_archive)
676 if ( params.DO_INSTALL && server_id != null) {
678 if (error && params.SAVE_CONTAINER_ON_FAIL ) {
681 if (!error && params.SAVE_CONTAINER_ON_PASS ) {
686 if (server_id != null) {
687 println("Deleting VM: $server_id")
689 for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done
690 openstack server delete ${server_id}
693 println("Saved VM $server_id in ETSI VIM")
697 if ( http_server_name != null ) {
698 sh "docker stop ${http_server_name} || true"
699 sh "docker rm ${http_server_name} || true"
702 if ( devopstempdir != null ) {
703 sh "rm -rf ${devopstempdir}"