Skip to content

Commit

Permalink
aws-test: tag and push an alpha of the oscontainer
Browse files Browse the repository at this point in the history
In #150, it was discussed that an `alpha` tag should be
made for the oscontainer (and cloud image) after it passes the tests
run in AWS.  This change accomplishes this goal by pulling the
oscontainer by commit ID, tagging it as `alpha` and pushing it to the
registry.  (After a successful test, obviously)

If the AWS tests fail, the image tagged with the ostree commit is
garbage collected and no alpha promotion happens.
  • Loading branch information
miabbott committed Sep 26, 2018
1 parent 84c9d7b commit 120d657
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Jenkinsfile.aws-test
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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") {
Expand All @@ -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")
Expand All @@ -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

Expand All @@ -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}
"""
}
}
Expand Down

0 comments on commit 120d657

Please sign in to comment.