Skip to content

Commit

Permalink
Identify suitable docker image SHA on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Stewart X Addison <[email protected]>
  • Loading branch information
sxa committed Aug 19, 2024
1 parent 69b82a5 commit 9f60c86
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pipelines/build/common/openjdk_build_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,7 @@ class Build {
// Perform a git clean outside of checkout to avoid the Jenkins enforced 10 minute timeout
// https://github.com/adoptium/infrastucture/issues/1553
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {

context.sh(script: 'git config --global safe.directory $(cygpath ${WORKSPACE})')
}
context.sh(script: 'git clean -fdx')
Expand Down Expand Up @@ -2067,7 +2068,11 @@ class Build {
}
}
// Store the pulled docker image digest as 'buildinfo'
dockerImageDigest = context.sh(script: "docker inspect --format='{{.RepoDigests}}' ${buildConfig.DOCKER_IMAGE}", returnStdout:true)
if ( buildConfig.TARGET_OS == 'windows' && buildConfig.DOCKER_IMAGE ) {
dockerImageDigest = context.sh(script: "docker inspect --format={{.Id}} ${buildConfig.DOCKER_IMAGE} | /bin/cut -d: -f2", returnStdout:true)
} else {
dockerImageDigest = context.sh(script: "docker inspect --format='{{.RepoDigests}}' ${buildConfig.DOCKER_IMAGE}", returnStdout:true)
}

// Use our dockerfile if DOCKER_FILE is defined
if (buildConfig.DOCKER_FILE) {
Expand Down Expand Up @@ -2102,7 +2107,7 @@ class Build {
}
} else {
dockerImageDigest = dockerImageDigest.replaceAll("\\[", "").replaceAll("\\]", "")
String dockerRunArg="-e BUILDIMAGESHA=abcde --init"
String dockerRunArg="-e \"BUILDIMAGESHA=$dockerImageDigest\" --init"

// Are we running podman in Docker CLI Emulation mode?
def isPodman = context.sh(script: "docker --version | grep podman", returnStatus:true)
Expand Down

0 comments on commit 9f60c86

Please sign in to comment.