+///////////////////////////////////////////////////////////////////////////////////////
+// Build docker containers
+///////////////////////////////////////////////////////////////////////////////////////
+ dir(OSM_DEVOPS) {
+ Map remote = [:]
+ error = null
+ if ( params.DO_BUILD ) {
+ withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry',
+ usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
+ sh "docker login ${INTERNAL_DOCKER_REGISTRY} -u ${USERNAME} -p ${PASSWORD}"
+ }
+ datetime = sh(returnStdout: true, script: 'date +%Y-%m-%d:%H:%M:%S').trim()
+ moduleBuildArgs = " --build-arg CACHE_DATE=${datetime}"
+ for (packageName in builtModules.keySet()) {
+ envName = packageName.replaceAll('-', '_').toUpperCase() + '_URL'
+ moduleBuildArgs += " --build-arg ${envName}=" + builtModules[packageName]
+ }
+ dir('docker') {
+ stage('Build') {
+ containerList = sh(returnStdout: true, script:
+ "find . -name Dockerfile -printf '%h\\n' | sed 's|\\./||'")
+ containerList = Arrays.asList(containerList.split('\n'))
+ print(containerList)
+ parallelSteps = [:]
+ for (buildStep in containerList) {
+ def module = buildStep
+ def moduleName = buildStep.toLowerCase()
+ def moduleTag = containerName
+ parallelSteps[module] = {
+ dir("$module") {
+ sh("""docker build --build-arg APT_PROXY=${APT_PROXY} \
+ -t opensourcemano/${moduleName}:${moduleTag} ${moduleBuildArgs} .""")
+ println("Tagging ${moduleName}:${moduleTag}")
+ sh("""docker tag opensourcemano/${moduleName}:${moduleTag} \
+ ${INTERNAL_DOCKER_REGISTRY}opensourcemano/${moduleName}:${moduleTag}""")
+ sh("""docker push \
+ ${INTERNAL_DOCKER_REGISTRY}opensourcemano/${moduleName}:${moduleTag}""")
+ }
+ }
+ }
+ parallel parallelSteps
+ }
+ }
+ } // if (params.DO_BUILD)
+
+ if (params.DO_INSTALL) {
+///////////////////////////////////////////////////////////////////////////////////////
+// Launch VM
+///////////////////////////////////////////////////////////////////////////////////////
+ stage('Spawn Remote VM') {
+ println('Launching new VM')
+ output = sh(returnStdout: true, script: """#!/bin/sh -e
+ for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done
+ openstack server create --flavor osm.sanity \
+ --image ${OPENSTACK_BASE_IMAGE} \
+ --key-name CICD \
+ --property build_url="${BUILD_URL}" \
+ --nic net-id=osm-ext \
+ ${containerName}
+ """).trim()
+
+ server_id = get_value('id', output)
+
+ if (server_id == null) {
+ println('VM launch output: ')
+ println(output)
+ throw new Exception('VM Launch failed')
+ }
+ println("Target VM is ${server_id}, waiting for IP address to be assigned")