Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve testenv.properties "-ga" tags to the actual openjdk build tag for scm_ref check #967

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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