X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=jenkins%2Fci-pipelines%2Fci_helper.groovy;h=21a8373f2f0961b41e87861bbeb2e18f5e1d8d4c;hb=refs%2Fchanges%2F02%2F5702%2F1;hp=974cd8d0a024f8991a3e50d828429adacfbc88b5;hpb=4c010284a3ad1782e039fcb6853a25516e6eb6c9;p=osm%2Fdevops.git diff --git a/jenkins/ci-pipelines/ci_helper.groovy b/jenkins/ci-pipelines/ci_helper.groovy index 974cd8d0..21a8373f 100644 --- a/jenkins/ci-pipelines/ci_helper.groovy +++ b/jenkins/ci-pipelines/ci_helper.groovy @@ -15,10 +15,8 @@ * under the License. */ -artifactory_server_id = 'artifactory-osm' - -def get_archive(mdg, branch, build_name, build_number, pattern='*') { - server = Artifactory.server artifactory_server_id +def get_archive(artifactory_server, mdg, branch, build_name, build_number, pattern='*') { + server = Artifactory.server artifactory_server println("retrieve archive for ${mdg}/${branch}/${build_name}/${build_number}/${pattern}") @@ -27,7 +25,7 @@ def get_archive(mdg, branch, build_name, build_number, pattern='*') { "files": [ { "target": "./", - "pattern": "${repo_prefix}${mdg}/${pattern}", + "pattern": "${repo_prefix}${mdg}/${branch}/${pattern}", "build": "${build_name}/${build_number}" } ] @@ -35,8 +33,8 @@ def get_archive(mdg, branch, build_name, build_number, pattern='*') { server.download(downloadSpec) // workaround. flatten and repo the specific build num from the directory - sh "cp -R ${build_num}/* ." - sh "rm -rf ${build_num}" + sh "cp -R ${branch}/${build_num}/* ." + sh "rm -rf ${branch}/${build_num}" } def get_env_value(build_env_file,key) { @@ -47,6 +45,10 @@ def lxc_run(container_name,cmd) { 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) { @@ -59,12 +61,22 @@ def lxc_get_file(container_name,file,destination) { 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",'.') } @@ -72,8 +84,8 @@ def get_ip_from_container( container_name ) { return sh(returnStdout: true, script: "lxc list ${container_name} -c 4|grep eth0 |awk '{print \$2}'").trim() } -def archive(mdg,branch,status) { - server = Artifactory.server artifactory_server_id +def archive(artifactory_server,mdg,branch,status) { + server = Artifactory.server artifactory_server def properties = "branch=${branch};status=${status}" def repo_prefix = 'osm-' @@ -81,19 +93,19 @@ def archive(mdg,branch,status) { "files": [ { "pattern": "dists/*.gz", - "target": "${repo_prefix}${mdg}/${BUILD_NUMBER}/", + "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/", "props": "${properties}", "flat": false }, { "pattern": "dists/*Packages", - "target": "${repo_prefix}${mdg}/${BUILD_NUMBER}/", + "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/", "props": "${properties}", "flat": false }, { "pattern": "pool/*/*.deb", - "target": "${repo_prefix}${mdg}/${BUILD_NUMBER}/", + "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/", "props": "${properties}", "flat": false }] @@ -113,10 +125,10 @@ def archive(mdg,branch,status) { //CANNOT use build promotion with OSS version of artifactory // For now, will publish downloaded artifacts into a new repo. -def promote_build(mdg,branch,buildInfo) { +def promote_build(artifactory_server,mdg,branch,buildInfo) { println("Promoting build: mdg: ${mdg} branch: ${branch} build: ${buildInfo.name}/${buildInfo.number}") - server = Artifactory.server artifactory_server_id + server = Artifactory.server artifactory_server //def properties = "branch=${branch};status=${status}" def repo_prefix = 'osm-'