X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=jenkins%2Fci-pipelines%2Fci_helper.groovy;h=1e724ff7a522c47d9514c130ed03a068a1263c09;hb=706fe53cc16f91319c16f2c7a3136d1b0d3aa2b6;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..1e724ff7 100644 --- a/jenkins/ci-pipelines/ci_helper.groovy +++ b/jenkins/ci-pipelines/ci_helper.groovy @@ -15,28 +15,30 @@ * 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}") + // if the build name does not contain merge, then this is a patchset/staging job + if (!build_name.contains('merge')) { + branch += '-staging' + } def repo_prefix = 'osm-' def downloadSpec = """{ "files": [ { "target": "./", - "pattern": "${repo_prefix}${mdg}/${pattern}", + "pattern": "${repo_prefix}${mdg}/${branch}/${build_number}/${pattern}", "build": "${build_name}/${build_number}" } ] }""" server.download(downloadSpec) - // workaround. flatten and repo the specific build num from the directory - sh "cp -R ${build_num}/* ." - sh "rm -rf ${build_num}" + // workaround. flatten repo to remove specific build num from the directory + sh "cp -R ${branch}/${build_num}/* ." + sh "rm -rf ${branch}/${build_num}" } def get_env_value(build_env_file,key) { @@ -47,24 +49,40 @@ 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) { sh "docker run -dit --name ${server_name} -v ${repo_dir}:/usr/local/apache2/htdocs/ httpd:2.4" def http_server_ip = sh(returnStdout:true, script: "docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${server_name}").trim() - return "-u http://${http_server_ip}/" + return "http://${http_server_ip}/" } 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) + result = lxc_run(container_name, "sh -c '. ${pre_source}; make -C devops/systest OSM_HOSTNAME=${so_ip} OSM_RO_HOSTNAME=${ro_ip} ${test}'") + echo result + } + else + { + result = lxc_run(container_name, "make -C devops/systest OSM_HOSTNAME=${so_ip} OSM_RO_HOSTNAME=${ro_ip} ${test}") + echo result + } lxc_get_file(container_name, "/root/devops/systest/reports/pytest-${test}.xml",'.') } @@ -72,28 +90,40 @@ 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 properties = "" + //def properties = "branch=${branch};status=${status}" def repo_prefix = 'osm-' + + // if the build name does not contain merge, then this is a patchset/staging job + if ( !JOB_NAME.contains('merge') ) { + branch += '-staging' + } def uploadSpec = """{ "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 + }, + { + "pattern": "changelog/*", + "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/", "props": "${properties}", "flat": false }] @@ -113,10 +143,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-'