stage_4 support
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
Change-Id: Ic997b0baf6ad9cedf486a506f050e016a0c5796a
diff --git a/jenkins/ci-pipelines/ci_helper.groovy b/jenkins/ci-pipelines/ci_helper.groovy
index c047a12..21a8373 100644
--- a/jenkins/ci-pipelines/ci_helper.groovy
+++ b/jenkins/ci-pipelines/ci_helper.groovy
@@ -45,6 +45,10 @@
return sh(returnStdout: true, script: "lxc exec ${container_name} -- ${cmd}").trim()
}
+def lxc_file_push(container_name,file,destination) {
+ return sh(returnStdout: true, script: "lxc file push ${file} ${container_name}/${destination}").trim()
+}
+
// start a http server
// return the http server URL
def start_http_server(repo_dir,server_name) {
@@ -57,12 +61,22 @@
sh "lxc file pull ${container_name}/${file} ${destination}"
}
-def systest_run(container_name, test) {
+def systest_run(container_name, test, source_rc = null) {
// need to get the SO IP inside the running container
so_ip = lxc_run(container_name,"lxc list SO-ub -c 4|grep eth0 |awk '{print \$2}'")
+ ro_ip = lxc_run(container_name,"lxc list RO -c 4|grep eth0 |awk '{print \$2}'")
//container_ip = get_ip_from_container(container_name)
- //
- lxc_run(container_name, "make -C devops/systest OSM_HOSTNAME=${so_ip} ${test}")
+
+ if ( source_rc ) {
+ pre_source = "/tmp/" + source_rc.substring(source_rc.lastIndexOf('/')+1)
+
+ lxc_file_push(container_name,source_rc,pre_source)
+ lxc_run(container_name, "sh -c '. ${pre_source}; make -C devops/systest OSM_HOSTNAME=${so_ip} OSM_RO_HOSTNAME=${ro_ip} ${test}'")
+ }
+ else
+ {
+ lxc_run(container_name, "make -C devops/systest OSM_HOSTNAME=${so_ip} OSM_RO_HOSTNAME=${ro_ip} ${test}")
+ }
lxc_get_file(container_name, "/root/devops/systest/reports/pytest-${test}.xml",'.')
}
diff --git a/jenkins/ci-pipelines/ci_stage_1.groovy b/jenkins/ci-pipelines/ci_stage_1.groovy
index 69b9018..117265a 100644
--- a/jenkins/ci-pipelines/ci_stage_1.groovy
+++ b/jenkins/ci-pipelines/ci_stage_1.groovy
@@ -48,6 +48,11 @@
stage_name = "stage_2"
break
}
+ do_stage_4 = false
+ if (params.DO_STAGE_4)
+ {
+ do_stage_4 = params.DO_STAGE_4
+ }
// pipeline running from gerrit trigger.
// kickoff the downstream multibranch pipeline
@@ -58,6 +63,7 @@
string(name: 'GERRIT_PATCHSET_REVISION', value: GERRIT_PATCHSET_REVISION),
string(name: 'PROJECT_URL_PREFIX', value: params.PROJECT_URL_PREFIX),
booleanParam(name: 'TEST_INSTALL', value: params.TEST_INSTALL),
+ booleanParam(name: 'DO_STAGE_4', value: do_stage_4),
]
if ( params.STAGE )
diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy
index d51c298..7620111 100644
--- a/jenkins/ci-pipelines/ci_stage_2.groovy
+++ b/jenkins/ci-pipelines/ci_stage_2.groovy
@@ -26,8 +26,8 @@
}
}
-def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,build_system,artifactory_server,docker_args="") {
- println("build_system = ${build_system}")
+def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifactory_server,docker_args="",do_stage_4=false) {
+ println("do_stage_3= ${do_stage_3}")
ci_helper = load "devops/jenkins/ci-pipelines/ci_helper.groovy"
stage('Prepare') {
@@ -66,13 +66,14 @@
ci_helper.archive(artifactory_server,mdg,branch,'untested')
}
- if ( build_system ) {
+ if ( do_stage_3 ) {
stage('Build System') {
def downstream_params_stage_3 = [
string(name: 'GERRIT_BRANCH', value: "${branch}"),
string(name: 'UPSTREAM_JOB_NAME', value: "${JOB_NAME}" ),
string(name: 'UPSTREAM_JOB_NUMBER', value: "${BUILD_NUMBER}" ),
+ booleanParam(name: 'DO_STAGE_4', value: do_stage_4 )
]
stage_3_job = "osm-stage_3"
if ( JOB_NAME.contains('merge') ) {
diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy
index 082f728..9ea2d7f 100644
--- a/jenkins/ci-pipelines/ci_stage_3.groovy
+++ b/jenkins/ci-pipelines/ci_stage_3.groovy
@@ -30,8 +30,10 @@
string(defaultValue: '', description: '', name: 'UPSTREAM_JOB_NUMBER'),
string(defaultValue: 'dpkg1', description: '', name: 'GPG_KEY_NAME'),
string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'),
+ string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'),
booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
- booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS')
+ booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'),
+ booleanParam(defaultValue: false, description: '', name: 'DO_STAGE_4'),
])
])
@@ -181,11 +183,22 @@
"""
}
- stage("Test") {
+ stage("Smoke") {
ci_helper.systest_run(container_name, 'smoke')
junit '*.xml'
}
+ if ( params.DO_STAGE_4 ) {
+ stage("stage_4") {
+ def downstream_params = [
+ string(name: 'CONTAINER_NAME', value: container_name),
+ ]
+ stage_4_result = build job: "${params.DOWNSTREAM_STAGE_NAME}/${GERRIT_BRANCH}", parameters: downstream_params, propagate: false
+
+ currentBuild.result = stage_4_result.result
+ }
+ }
+
// save the artifacts of this build if this is a merge job
if ( save_artifacts ) {
stage("Archive") {
@@ -200,6 +213,7 @@
}
}
catch(caughtError) {
+ println("Caught error!")
error = caughtError
currentBuild.result = 'FAILURE'
}
diff --git a/jenkins/ci-pipelines/ci_stage_4.groovy b/jenkins/ci-pipelines/ci_stage_4.groovy
index 928fdd8..5e390e3 100644
--- a/jenkins/ci-pipelines/ci_stage_4.groovy
+++ b/jenkins/ci-pipelines/ci_stage_4.groovy
@@ -17,9 +17,10 @@
properties([
parameters([
+ string(defaultValue: '', description: '', name: 'CONTAINER_NAME' ),
string(defaultValue: 'osm-stage_3', description: '', name: 'UPSTREAM_PROJECT'),
- string(defaultValue: 'release', description: '', name: 'RELEASE'),
string(defaultValue: 'pipeline', description: '', name: 'NODE'),
+ string(defaultValue: '/home/jenkins/hive/openstack-telefonica.rc', description: '', name: 'HIVE_VIM_1'),
])
])
@@ -31,25 +32,26 @@
ci_helper = load "jenkins/ci-pipelines/ci_helper.groovy"
- stage("get artifacts") {
- // grab the upstream artifact name
+ if ( params.CONTAINER_NAME ) {
+ container_name = params.CONTAINER_NAME
+ }
+ else if ( params.UPSTREAM_PROJECT ) {
step ([$class: 'CopyArtifact',
projectName: "${params.UPSTREAM_PROJECT}/${BRANCH_NAME}"])
+ container_name = sh(returnStdout: true, script: 'cat build_version.txt').trim()
}
-
- container_name = sh(returnStdout: true, script: 'cat build_version.txt').trim()
-
- stage("Test") {
- ci_helper.systest_run(container_name, 'smoke')
- junit '*.xml'
+ else {
+ println("no OSM container found")
+ currentBuild.result = 'FAILURE'
+ return
}
+ println("OSM container = ${container_name}")
-/* os_credentials = "OS_AUTH_URL=${params.OS_AUTH_URL} OS_USERNAME=${params.OS_USERNAME} OS_PASSWORD=${params.OS_PASSWORD} OS_PROJECT_NAME=${params.OS_PROJECT_NAME}"
- stage("cirros-test") {
- sh """
- make -C systest OSM_HOSTNAME=${osm_ip} ${os_credentials} cirros
- """
- junit 'systest/reports/pytest-cirros.xml'
+ if ( params.HIVE_VIM_1 ) {
+ stage( "${params.HIVE_VIM_1}" ) {
+ ci_helper.systest_run(container_name, 'cirros', params.HIVE_VIM_1)
+ ci_helper.systest_run(container_name, 'ns_scale', params.HIVE_VIM_1)
+ junit '*.xml'
}
-*/
+ }
}
diff --git a/jenkins/common/install_common b/jenkins/common/install_common
index 3884b0e..b769014 100755
--- a/jenkins/common/install_common
+++ b/jenkins/common/install_common
@@ -21,7 +21,7 @@
REPOSITORY="stable"
REPOSITORY_BASE="http://osm-download.etsi.org/repository/osm/debian"
-while getopts ":r:k:u:R:b:" o; do
+while getopts ":r:k:u:R:b:-:" o; do
case "${o}" in
r)
REPOSITORY=${OPTARG}
@@ -38,6 +38,8 @@
b)
## ignore branch option
;;
+ -)
+ ;;
esac
done
diff --git a/jenkins/system/start_build b/jenkins/system/start_build
index e1b91ac..03fe930 100755
--- a/jenkins/system/start_build
+++ b/jenkins/system/start_build
@@ -53,7 +53,7 @@
systemctl enable lxd-bridge
systemctl start lxd-bridge
-apt-get install -y python-pip python python-pycurl charm-tools python-pytest
+apt-get install -y python-pip python python-pycurl charm-tools python-pytest python-openstackclient
apt-get install -y python-osmclient