Skip to content

Commit

Permalink
Resolve testenv.properties "-ga" tags to the actual openjdk build tag…
Browse files Browse the repository at this point in the history
… for scm_ref check (adoptium#967)

* Update release testenv jdkBranch check to resolve -ga commit

Signed-off-by: Andrew Leonard <[email protected]>

* Update release testenv jdkBranch check to resolve -ga commit

Signed-off-by: Andrew Leonard <[email protected]>

* Update release testenv jdkBranch check to resolve -ga commit

Signed-off-by: Andrew Leonard <[email protected]>

---------

Signed-off-by: Andrew Leonard <[email protected]>
  • Loading branch information
andrew-m-leonard committed Mar 13, 2024
1 parent 8ce200e commit 267747b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions pipelines/build/openjdk_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,46 @@ Closure configureBuild = null
def buildConfigurations = null
Map<String, ?> DEFAULTS_JSON = null


// Resolve a "-ga" tag to the actual upstream openjdk build tag of the same commit
// Also check adoptium mirror for "dryrun" tags
def resolveGaTag(String jdkVersion, String jdkBranch) {
def resolvedTag = jdkBranch // Default to as-is

def openjdkRepo = "https://github.com/openjdk/jdk${jdkVersion}.git"

def gaCommitSHA = sh(returnStdout: true, script:"git ls-remote --tags ${openjdkRepo} | grep '\\^{}' | grep \"${jdkBranch}\" | tr -s '\\t ' ' ' | cut -d' ' -f1 | tr -d '\\n'")
if (gaCommitSHA == "") {
// Try "updates" repo..
openjdkRepo = "https://github.com/openjdk/jdk${jdkVersion}u.git"
gaCommitSHA = sh(returnStdout: true, script:"git ls-remote --tags ${openjdkRepo} | grep '\\^{}' | grep \"${jdkBranch}\" | tr -s '\\t ' ' ' | cut -d' ' -f1 | tr -d '\\n'")
}
if (gaCommitSHA == "") {
// Maybe an Adoptium "dryrun" try Adoptium mirror repo..
openjdkRepo = "https://github.com/adoptium/jdk${jdkVersion}.git"
gaCommitSHA = sh(returnStdout: true, script:"git ls-remote --tags ${openjdkRepo} | grep '\\^{}' | grep \"${jdkBranch}\" | tr -s '\\t ' ' ' | cut -d' ' -f1 | tr -d '\\n'")
}
if (gaCommitSHA == "") {
// Maybe an Adoptium "dryrun" try Adoptium mirror "updates" repo..
openjdkRepo = "https://github.com/adoptium/jdk${jdkVersion}u.git"
gaCommitSHA = sh(returnStdout: true, script:"git ls-remote --tags ${openjdkRepo} | grep '\\^{}' | grep \"${jdkBranch}\" | tr -s '\\t ' ' ' | cut -d' ' -f1 | tr -d '\\n'")
}

if (gaCommitSHA == "") {
println "[ERROR] Unable to resolve ${jdkBranch} upstream commit, will try to match tag as-is"
} else {
def upstreamTag = sh(returnStdout: true, script:"git ls-remote --tags ${openjdkRepo} | grep '\\^{}' | grep \"${gaCommitSHA}\" | grep -v \"${jdkBranch}\" | tr -s '\\t ' ' ' | cut -d' ' -f2 | sed \"s,refs/tags/,,\" | sed \"s,\\^{},,\" | tr -d '\\n'")
if (upstreamTag != "") {
println "[INFO] Resolved ${jdkBranch} to upstream build tag ${upstreamTag}"
resolvedTag = upstreamTag
} else {
println "[ERROR] Unable to resolve ${jdkBranch} upstream commit, will try to match tag as-is"
}
}

return resolvedTag
}

node('worker') {
// Ensure workspace is clean so we don't archive any old failed pipeline artifacts
println '[INFO] Cleaning up controller worker workspace prior to running pipelines..'
Expand Down Expand Up @@ -57,6 +97,12 @@ node('worker') {
break
}
}

// If testenv tag is a "-ga" tag, then resolve to the actual openjdk build tag it's tagging
if (jdkBranch.contains("-ga")) {
jdkBranch = resolveGaTag("${params.jdkVersion}", jdkBranch)
}

if (jdkBranch == buildTag) {
println "[INFO] scmReference=${buildTag} matches with JDK${params.jdkVersion}_BRANCH=${jdkBranch} in ${propertyFile} in aqa-tests release branch."
} else if (jdkOpenj9Branch == buildTag) {
Expand Down

0 comments on commit 267747b

Please sign in to comment.