diff --git a/Jenkinsfile.aws-test b/Jenkinsfile.aws-test index e53abd931..cd3e1973b 100644 --- a/Jenkinsfile.aws-test +++ b/Jenkinsfile.aws-test @@ -1,5 +1,8 @@ def NODE = "rhcos-jenkins" def AWS_REGION = "us-east-1" +def API_CI_REGISTRY = "registry.svc.ci.openshift.org" +def OS_NAME = "maipo"; +def OSCONTAINER_IMG = API_CI_REGISTRY + "/rhcos/os-${OS_NAME}" // this var conveniently refers to a location on the server as well as the // local dir we sync to/from @@ -24,7 +27,7 @@ node(NODE) { // We're only ever triggered by the cloud job, so we know the latest build is in latest/ // We immediately resolve it back to the specific images/ dir - def dirpath, version + def dirpath, version, ostree_commit try { utils.inside_assembler_container("-v /srv:/srv") { stage("Sync In") { @@ -35,6 +38,7 @@ node(NODE) { dirpath = "${images}/cloud/latest" sh "mkdir -p ${dirpath}" utils.rsync_file_in(ARTIFACT_SERVER, KEY_FILE, "${dirpath}/meta.json") + ostree_commit = utils.sh_capture("jq -r '.[\"ostree-commit\"]' ${dirpath}/meta.json" version = utils.sh_capture("jq -r '.[\"ostree-version\"]' ${dirpath}/meta.json") # resolve to original dir to avoid races in the next rsync in def imgv = utils.sh_capture("jq -r '.[\"image-version\"]' ${dirpath}/meta.json") @@ -53,12 +57,20 @@ node(NODE) { string(credentialsId: params.S3_PRIVATE_BUCKET, variable: 'S3_PRIVATE_BUCKET'), string(credentialsId: params.AWS_CI_ACCOUNT, variable: 'AWS_CI_ACCOUNT'), string(credentialsId: params.S3_PUBLIC_BUCKET, variable: 'S3_PUBLIC_BUCKET'), + usernameColonPassword(credentialsId: params.REGISTRY_CREDENTIALS, variable: 'CREDS'), ]) { + // login to registry and setup container storage + def (registryUser, registryPass) = "${CREDS}".split(':') + utils.registry_login(registryUser, registryPass, "${API_CI_REGISTRY}") + utils.prep_container_storage("${WORKSPACE}") + def ami_intermediate = utils.sh_capture("jq -r .HVM ${dirpath}/aws-${AWS_REGION}.json") currentBuild.description = "version=${version} ami=${ami_intermediate}" sh """ # Do testing with intermediate aws image passed in by cloud job if ! kola -b rhcos -p aws --aws-type t2.small --tapfile rhcos-aws.tap --aws-ami ${ami_intermediate} --aws-region ${AWS_REGION} -j ${NUM_VMS} run; then + # if the tests fail, GC the container image tagged with the ostree commit + skopeo delete docker://${OSCONTAINER_IMG}:${ostree_commit} exit 1 fi @@ -82,6 +94,12 @@ node(NODE) { aws s3 cp --acl public-read \ ${images}/aws-${AWS_REGION}-tested.json \ s3://${S3_PUBLIC_BUCKET}/aws-${AWS_REGION}-tested.json + + # Tag the container image to alpha, then GC the image tagged with the ostree commit + podman pull ${OSCONTAINER_IMG}:${ostree_commit} + podman tag ${OSCONTAINER_IMG}:${ostree_commit} ${OSCONTAINER_IMG}:alpha + podman push ${OSCONTAINER_IMG}:alpha + skopeo delete docker://${OSCONTAINER_IMG}:${ostree_commit} """ } }