Skip to content

Commit

Permalink
jobs/build-kola-containers: Call skopeo from cosa
Browse files Browse the repository at this point in the history
The skopeo call to check for changes was running outside of cosa
where the binary is not available. This only started to cause issues
recently somehow
  • Loading branch information
jbtrystram authored and aaradhak committed May 14, 2024
1 parent 434075d commit 96f4a65
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions jobs/build-kola-containers.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,6 @@ node {
cd ${path}
find . -maxdepth 1 -mindepth 1 -type d -exec basename {} \\;
""").trim().split("\n")

if ( !params.FORCE ) {
// get the git commit ref for the last built container
def previous_ref = shwrapCapture("""
skopeo inspect --no-creds docker://${params.CONTAINER_REGISTRY_ORG}/${contexts[0]}:latest \
| jq -r '.Labels.org.opencontainers.image.revision'
""")

// Check for changes in tests/containers/* since the last build
// If none, no need to run this
changeset = shwrapRc("git diff --quiet ${previous_ref} -- ${path}")
} else {
changeset = 1
}
}

if ( changeset == 0 ) {
currentBuild.result = 'SUCCESS'
currentBuild.description = "[${gitref}@${shortcommit}] 💤 (no change)."
return
} else if ( changeset != 1 ) {
currentBuild.result = 'FAILURE'
currentBuild.description = "[${gitref}@${shortcommit}] ❌ Cannot determine changes. git diff return code ${changeset}."
message = "build-kola-test-containers #${env.BUILD_NUMBER} <${env.BUILD_URL}|:jenkins:> <${env.RUN_DISPLAY_URL}|:ocean:> [${gitref}@${shortcommit}]"
pipeutils.trySlackSend(message: message)
return
}

currentBuild.description = "[${gitref}@${shortcommit}] Waiting"
Expand All @@ -139,6 +113,34 @@ lock(resource: "build-kola-containers") {
timeout(time: 60, unit: 'MINUTES') {
try {

if ( !params.FORCE ) {
// get the git commit ref for the last built container
def previous_ref = shwrapCapture("""
skopeo inspect --no-creds docker://${params.CONTAINER_REGISTRY_ORG}/${contexts[0]}:latest \
| jq -r '.Labels.org.opencontainers.image.revision'
""")

// Check for changes in tests/containers/* since the last build
// If none, no need to run this
def path = params.PATH_TO_CONTEXTS
changeset = shwrapRc("git diff --quiet ${previous_ref} -- ${path}")

} else {
changeset = 1
}

if ( changeset == 0 ) {
currentBuild.result = 'SUCCESS'
currentBuild.description = "[${gitref}@${shortcommit}] 💤 (no change)."
return
} else if ( changeset != 1 ) {
currentBuild.result = 'FAILURE'
currentBuild.description = "[${gitref}@${shortcommit}] ❌ Cannot determine changes. git diff return code ${changeset}."
message = "build-kola-test-containers #${env.BUILD_NUMBER} <${env.BUILD_URL}|:jenkins:> <${env.RUN_DISPLAY_URL}|:ocean:> [${gitref}@${shortcommit}]"
pipeutils.trySlackSend(message: message)
return
}

currentBuild.description = "[${gitref}@${shortcommit}] Running"

// By default we will allow re-using cache layers for one day.
Expand Down

0 comments on commit 96f4a65

Please sign in to comment.