From aa7dbd3fc05068b77f42e8698ea4dda3d02cc470 Mon Sep 17 00:00:00 2001 From: Mike Marchetti Date: Fri, 21 Sep 2018 15:46:43 -0400 Subject: [PATCH] Use osm-devops package for stage_3 Change-Id: Ie3d19c1886e48be14c484c32f75a48e35907f71e Signed-off-by: Mike Marchetti --- devops-stages/stage-archive.sh | 2 +- jenkins/ci-pipelines/ci_stage_3.groovy | 204 +++++++++++++------------ 2 files changed, 107 insertions(+), 99 deletions(-) diff --git a/devops-stages/stage-archive.sh b/devops-stages/stage-archive.sh index 2cffdd1d..b89e3c1f 100755 --- a/devops-stages/stage-archive.sh +++ b/devops-stages/stage-archive.sh @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -PKG_DIRECTORIES="jenkins installers systest juju-charms descriptor-packages tools" +PKG_DIRECTORIES="jenkins installers systest juju-charms descriptor-packages tools docker" MDG_NAME=devops DEB_INSTALL=debian/osm-$MDG_NAME.install export DEBEMAIL="mmarchetti@sandvine.com" diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 503b3137..a788f7bd 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -159,122 +159,130 @@ node("${params.NODE}") { pwd = sh(returnStdout:true, script: 'pwd').trim() repo_base_url = ci_helper.start_http_server(pwd,http_server_name) } - } - error = null - if ( params.DO_BUILD ) { - stage("Build") { - sh "make -C docker clean" - sh "make -j4 -C docker CMD_DOCKER_ARGS= TAG=${container_name} RELEASE=${params.RELEASE} REPOSITORY_BASE=${repo_base_url} REPOSITORY_KEY=${params.REPO_KEY_NAME} REPOSITORY=${params.REPO_DISTRO}" - } + // now pull the devops package and install in temporary location + tempdir = sh(returnStdout: true, script: "mktemp -d").trim() + osm_devops_dpkg = sh(returnStdout: true, script: "find . -name osm-devops*.deb").trim() + sh "dpkg -x ${osm_devops_dpkg} ${tempdir}" + OSM_DEVOPS="${tempdir}/usr/share/osm-devops" } - try { - if ( params.DO_INSTALL ) { - stage("Install") { - - //will by default always delete containers on complete - //sh "jenkins/system/delete_old_containers.sh ${container_name_prefix}" - - commit_id = '' - repo_distro = '' - repo_key_name = '' - release = '' - - if ( params.COMMIT_ID ) - { - commit_id = "-b ${params.COMMIT_ID}" - } + dir(OSM_DEVOPS) { + error = null + if ( params.DO_BUILD ) { + stage("Build") { + sh "make -C docker clean" + sh "make -j4 -C docker CMD_DOCKER_ARGS= TAG=${container_name} RELEASE=${params.RELEASE} REPOSITORY_BASE=${repo_base_url} REPOSITORY_KEY=${params.REPO_KEY_NAME} REPOSITORY=${params.REPO_DISTRO}" + } + } - if ( params.REPO_DISTRO ) - { - repo_distro = "-r ${params.REPO_DISTRO}" + try { + if ( params.DO_INSTALL ) { + stage("Install") { + + //will by default always delete containers on complete + //sh "jenkins/system/delete_old_containers.sh ${container_name_prefix}" + + commit_id = '' + repo_distro = '' + repo_key_name = '' + release = '' + + if ( params.COMMIT_ID ) + { + commit_id = "-b ${params.COMMIT_ID}" + } + + if ( params.REPO_DISTRO ) + { + repo_distro = "-r ${params.REPO_DISTRO}" + } + + if ( params.REPO_KEY_NAME ) + { + repo_key_name = "-k ${params.REPO_KEY_NAME}" + } + + if ( params.RELEASE ) + { + release = "-R ${params.RELEASE}" + } + + sh """ + export PATH=$PATH:/snap/bin + installers/full_install_osm.sh -y -s ${container_name} --test --nolxd --nodocker --nojuju --nohostports --nohostclient \ + --nodockerbuild -t ${container_name} \ + -w /tmp/osm \ + ${commit_id} \ + ${repo_distro} \ + ${repo_base_url} \ + ${repo_key_name} \ + ${release} \ + ${params.BUILD_FROM_SOURCE} + """ } + } - if ( params.REPO_KEY_NAME ) - { - repo_key_name = "-k ${params.REPO_KEY_NAME}" + stage_archive = false + if ( params.DO_SMOKE ) { + stage("OSM Health") { + sh "installers/osm_health.sh -s ${container_name}" } - - if ( params.RELEASE ) - { - release = "-R ${params.RELEASE}" + stage("Smoke") { + run_systest(container_name,container_name,"smoke") + // archive smoke success until stage_4 is ready + stage_archive = params.SAVE_ARTIFACTS_ON_SMOKE_SUCCESS } - - sh """ - export PATH=$PATH:/snap/bin - installers/full_install_osm.sh -y -s ${container_name} --test --nolxd --nodocker --nojuju --nohostports --nohostclient \ - --nodockerbuild -t ${container_name} \ - -w /tmp/osm \ - ${commit_id} \ - ${repo_distro} \ - ${repo_base_url} \ - ${repo_key_name} \ - ${release} \ - ${params.BUILD_FROM_SOURCE} - """ - } - } - - stage_archive = false - if ( params.DO_SMOKE ) { - stage("OSM Health") { - sh "installers/osm_health.sh -s ${container_name}" - } - stage("Smoke") { - run_systest(container_name,container_name,"smoke") - // archive smoke success until stage_4 is ready - stage_archive = params.SAVE_ARTIFACTS_ON_SMOKE_SUCCESS } - } - if ( params.DO_STAGE_4 ) { - stage("stage_4") { - def downstream_params = [ - string(name: 'CONTAINER_NAME', value: container_name), - string(name: 'NODE', value: NODE_NAME.split()[0]), - ] - stage_4_result = build job: "${params.DOWNSTREAM_STAGE_NAME}/${GERRIT_BRANCH}", parameters: downstream_params, propagate: false - currentBuild.result = stage_4_result.result - - if ( stage_4_result.getResult().equals('SUCCESS') ) { - stage_archive = true; + if ( params.DO_STAGE_4 ) { + stage("stage_4") { + def downstream_params = [ + string(name: 'CONTAINER_NAME', value: container_name), + string(name: 'NODE', value: NODE_NAME.split()[0]), + ] + stage_4_result = build job: "${params.DOWNSTREAM_STAGE_NAME}/${GERRIT_BRANCH}", parameters: downstream_params, propagate: false + currentBuild.result = stage_4_result.result + + if ( stage_4_result.getResult().equals('SUCCESS') ) { + stage_archive = true; + } } } - } - // override to save the artifacts - if ( params.SAVE_ARTIFACTS_OVERRIDE || stage_archive ) { - stage("Archive") { - sh "echo ${container_name} > build_version.txt" - archiveArtifacts artifacts: "build_version.txt", fingerprint: true + // override to save the artifacts + if ( params.SAVE_ARTIFACTS_OVERRIDE || stage_archive ) { + stage("Archive") { + sh "echo ${container_name} > build_version.txt" + archiveArtifacts artifacts: "build_version.txt", fingerprint: true - // Archive the tested repo - dir("repo/${RELEASE}") { - ci_helper.archive(params.ARTIFACTORY_SERVER,RELEASE,GERRIT_BRANCH,'tested') + // Archive the tested repo + dir("repo/${RELEASE}") { + ci_helper.archive(params.ARTIFACTORY_SERVER,RELEASE,GERRIT_BRANCH,'tested') + } } } } - } - catch(caughtError) { - println("Caught error!") - error = caughtError - currentBuild.result = 'FAILURE' - } - finally { - sh "docker stop ${http_server_name}" - sh "docker rm ${http_server_name}" - - if ( params.DO_INSTALL ) { - if (error) { - if ( !params.SAVE_CONTAINER_ON_FAIL ) { - uninstall_osm container_name + catch(caughtError) { + println("Caught error!") + error = caughtError + currentBuild.result = 'FAILURE' + } + finally { + sh "docker stop ${http_server_name}" + sh "docker rm ${http_server_name}" + + if ( params.DO_INSTALL ) { + if (error) { + if ( !params.SAVE_CONTAINER_ON_FAIL ) { + uninstall_osm container_name + } + throw error } - throw error - } - else { - if ( !params.SAVE_CONTAINER_ON_PASS ) { - uninstall_osm container_name + else { + if ( !params.SAVE_CONTAINER_ON_PASS ) { + uninstall_osm container_name + } } } } -- 2.25.1