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 28, 2018
1 parent ed956eb commit e30a4ed
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 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}"

// location on the server we'll rsync to/from our $WORKSPACE
def images = "/srv/rhcos/output/images"
Expand All @@ -23,7 +26,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 version
def ostree_commit, version
try {
utils.inside_assembler_container("") {
stage("Sync In") {
Expand All @@ -32,6 +35,7 @@ node(NODE) {
sshUserPrivateKey(credentialsId: params.ARTIFACT_SSH_CREDS_ID, keyFileVariable: 'KEY_FILE'),
]) {
utils.rsync_file_in_dest(ARTIFACT_SERVER, KEY_FILE, "${images}/cloud/latest/meta.json", "${WORKSPACE}/meta.json")
ostree_commit = utils.sh_capture("jq -r '.[\"ostree-commit\"]' ${WORKSPACE}/meta.json")
version = utils.sh_capture("jq -r '.[\"ostree-version\"]' ${WORKSPACE}/meta.json")
// resolve to original dir to avoid races in the next rsync in
def imgv = utils.sh_capture("jq -r '.[\"image-version\"]' ${WORKSPACE}/meta.json")
Expand All @@ -48,12 +52,21 @@ 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'),
]) {
def ami_intermediate = utils.sh_capture("jq -r .HVM ${WORKSPACE}/aws-${AWS_REGION}.json")

// 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}")

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 @@ -71,6 +84,10 @@ node(NODE) {
aws s3 cp --acl public-read \
${WORKSPACE}/aws-${AWS_REGION}.json \
s3://${S3_PUBLIC_BUCKET}/aws-${AWS_REGION}-tested.json

# Copy the container image to alpha, then GC the image tagged with the ostree commit
skopeo copy docker://${OSCONTAINER_IMG}:${ostree_commit} docker://${OSCONTAINER_IMG}:alpha
skopeo delete docker://${OSCONTAINER_IMG}:${ostree_commit}
"""
}
}
Expand Down

0 comments on commit e30a4ed

Please sign in to comment.