X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=jenkins%2Fci-pipelines%2Fci_helper.groovy;h=4f1d32daf9c14499e48aa421dd1e3159aa9dd78a;hb=11a8a1e472867d2246228217f6736675e905c5d1;hp=243a13d00a1a56a42c577f9e8d843a5ef1336429;hpb=c121ff81ff1018d0f59af6d04503f3e8087e7c74;p=osm%2Fdevops.git diff --git a/jenkins/ci-pipelines/ci_helper.groovy b/jenkins/ci-pipelines/ci_helper.groovy index 243a13d0..4f1d32da 100644 --- a/jenkins/ci-pipelines/ci_helper.groovy +++ b/jenkins/ci-pipelines/ci_helper.groovy @@ -1,7 +1,7 @@ /* Copyright 2017 Sandvine * * All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at @@ -20,21 +20,36 @@ def get_archive(artifactory_server, mdg, branch, build_name, build_number, patte 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}/${branch}/${pattern}", - "build": "${build_name}/${build_number}" + "pattern": "${repo_prefix}${mdg}/${branch}/${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}" + println("Searching Artifactory with ${downloadSpec}") + + def results = server.download(downloadSpec) + // Save the list of URLs that we need to pass to the dockerfiles for build + def debian_packages = [] + for ( result in results.getDependencies() ) { + if (result.remotePath.contains(".deb")) { + debian_packages.add(result.remotePath) + } + } + + // workaround. flatten repo to remove specific build num from the directory + sh "cp -Rv ${branch}/${build_number}/* ." + sh "rm -rfv ${branch}/${build_number}" + + return debian_packages } def get_env_value(build_env_file,key) { @@ -45,24 +60,57 @@ 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 start_http_server(repo_dir,server_name,port) { + sh "docker run -dit --name ${server_name} -p ${port}:80 -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}:${port}/" +} + +def check_status_http_server(ip, port) { + alive = false + timeout(time: 1, unit: 'MINUTES') { + while (!alive) { + output = sh( + returnStatus: true, + script: "wget http://${ip}:${port}/release/dists/unstable/Release") + alive = (output == 0) + if (!alive) { + sleep(time: 5, unit: 'SECONDS') + } + } + } + println('HTTP server is ready and accepting http connections') + return } 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",'.') } @@ -73,8 +121,14 @@ def get_ip_from_container( container_name ) { 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": [ { @@ -94,6 +148,12 @@ def archive(artifactory_server,mdg,branch,status) { "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/", "props": "${properties}", "flat": false + }, + { + "pattern": "changelog/*", + "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/", + "props": "${properties}", + "flat": false }] }""" @@ -125,7 +185,7 @@ def promote_build(artifactory_server,mdg,branch,buildInfo) { "buildName" : buildInfo.name, "buildNumber" : buildInfo.number, 'targetRepo' : 'osm-release', - + // Optional parameters 'comment' : 'this is the promotion comment', 'sourceRepo' : "${repo_prefix}${mdg}",