From: Wesley Hirsch Date: Fri, 8 Sep 2017 21:42:29 +0000 (-0400) Subject: Make artifactory server configurable in Jenkins build X-Git-Tag: v3.0.0rc~10^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=92da206dcbbd4fdfa53459f0c253fa0cc671c7b9;p=osm%2Fdevops.git Make artifactory server configurable in Jenkins build Change-Id: Ibb00e5dbbbc15fcc3f73a045ccb99ab666cbccd6 Signed-off-by: Wesley Hirsch --- diff --git a/jenkins/ci-pipelines/ci_helper.groovy b/jenkins/ci-pipelines/ci_helper.groovy index 974cd8d0..a7312672 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}") @@ -72,8 +70,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-' @@ -113,10 +111,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-' diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index 45cbc7d6..d90ee2b2 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -26,7 +26,7 @@ def project_checkout(url_prefix,project,refspec,revision) { } } -def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,build_system) { +def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,build_system,artifactory_server) { println("build_system = ${build_system}") ci_helper = load "devops/jenkins/ci-pipelines/ci_helper.groovy" @@ -65,7 +65,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,build_system) { stage('Archive') { sh(returnStdout:true, script: 'devops-stages/stage-archive.sh').trim() - ci_helper.archive(mdg,branch,'untested') + ci_helper.archive(artifactory_server,mdg,branch,'untested') } if ( build_system ) { diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 6b1198bd..4c5712bb 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -29,6 +29,7 @@ properties([ string(defaultValue: '', description: '', name: 'UPSTREAM_JOB_NUMBER'), string(defaultValue: '', description: '', name: 'UPSTREAM_JOB_NUMBER'), string(defaultValue: 'dpkg1', description: '', name: 'GPG_KEY_NAME'), + string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'), booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'), booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'), ]) @@ -68,7 +69,7 @@ node("${params.NODE}") { //options = get_env_from_build('build.env') build_num = ci_helper.get_env_value('build.env','BUILD_NUMBER') //build_num = sh(returnStdout:true, script: "cat build.env | awk -F= '/BUILD_NUMBER/{print \$2}'").trim() - ci_helper.get_archive(component,GERRIT_BRANCH, "${component}-stage_2 :: ${GERRIT_BRANCH}", build_num) + ci_helper.get_archive(params.ARTIFACTORY_SERVER,component,GERRIT_BRANCH, "${component}-stage_2 :: ${GERRIT_BRANCH}", build_num) // cleanup any prevously defined dists sh "rm -rf dists" @@ -89,7 +90,7 @@ node("${params.NODE}") { build_num = ci_helper.get_env_value('build.env','BUILD_NUMBER') component = ci_helper.get_mdg_from_project(ci_helper.get_env_value('build.env','GERRIT_PROJECT')) - ci_helper.get_archive(component,GERRIT_BRANCH, "${component}-stage_2 :: ${GERRIT_BRANCH}", build_num) + ci_helper.get_archive(params.ARTIFACTORY_SERVER,component,GERRIT_BRANCH, "${component}-stage_2 :: ${GERRIT_BRANCH}", build_num) sh "rm -rf dists" } @@ -179,7 +180,7 @@ node("${params.NODE}") { // Archive the tested repo dir("repo/${RELEASE}") { - ci_helper.archive(RELEASE,GERRIT_BRANCH,'tested') + ci_helper.archive(params.ARTIFACTORY_SERVER,RELEASE,GERRIT_BRANCH,'tested') } } }