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

Fix/image name length #278

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
47 changes: 45 additions & 2 deletions vars/microservicePipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,29 @@ spec:
// handle feature branch image builds from forked repos
def isOpenSourceContribution = regexMatchRepoOwner[1] != "uc-cdis"
def currentBranchFormatted = isOpenSourceContribution ? "automatedCopy-${pipeConfig['currentBranchFormatted']}" : pipeConfig['currentBranchFormatted'];
println("### ## currentBranchFormatted: ${currentBranchFormatted}")
if (currentBranchFormatted.length() > 63) {
def newCurrentBranchFormatted = currentBranchFormatted.substring(0,63)
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" is longer than 63 characters. It will will be truncated to \"${newCurrentBranchFormatted}\"")
currentBranchFormatted = newCurrentBranchFormatted
def validImageTagName = currentBranchFormatted ==~ /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/
if (!validImageTagName) {
if (currentBranchFormatted.endsWith("-") || currentBranchFormatted.endsWith(".") || currentBranchFormatted.endsWith("_")) {
newCurrentBranchFormatted = currentBranchFormatted.substring(0,currentBranchFormatted.length()-1)+"0"
validImageTagName = newCurrentBranchFormatted ==~ /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/
if (validImageTagName) {
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" violates validation, it will be changed to \"${newCurrentBranchFormatted}\"")
currentBranchFormatted = newCurrentBranchFormatted
} else {
throw new Exception("currentBranchFormatted \"${currentBranchFormatted}\" violates validation and cannot be used")
}
} else {
throw new Exception("currentBranchFormatted \"${currentBranchFormatted}\" violates validation and cannot be used")
}
} else {
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" passes validation")
}
}
println("### ## currentBranchFormatted: ${currentBranchFormatted}")

if(!skipQuayBuild) {
if(pipeConfig.IMAGES_TO_BUILD != null && pipeConfig.IMAGES_TO_BUILD.size > 0){
Expand Down Expand Up @@ -354,6 +376,28 @@ spec:
)
} else if (pipeConfig.MANIFEST == null || pipeConfig.MANIFEST == false || pipeConfig.MANIFEST != "True") {
def quayBranchName = regexMatchRepoOwner[1] == "uc-cdis" ? pipeConfig.serviceTesting.branch : "automatedCopy-${pipeConfig.serviceTesting.branch}";
if (quayBranchName.length() > 63) {
def newQuayBranchName = quayBranchName.substring(0,63)
println("### ## quayBranchName \"${quayBranchName}\" is longer than 63 characters. It will will be truncated to \"${newQuayBranchName}\"")
quayBranchName = newQuayBranchName
def validImageTagName = quayBranchName ==~ /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/
if (!validImageTagName) {
if (quayBranchName.endsWith("-") || quayBranchName.endsWith(".") || quayBranchName.endsWith("_")) {
newQuayBranchName = quayBranchName.substring(0,quayBranchName.length()-1)+"0"
validImageTagName = newQuayBranchName ==~ /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/
if (validImageTagName) {
println("### ## quayBranchName \"${quayBranchName}\" violates validation, it will be changed to \"${newQuayBranchName}\"")
quayBranchName = newQuayBranchName
} else {
throw new Exception("quayBranchName \"${quayBranchName}\" violates validation and cannot be used")
}
} else {
throw new Exception("quayBranchName \"${quayBranchName}\" violates validation and cannot be used")
}
} else {
println("### ## quayBranchName \"${quayBranchName}\" passes validation")
}
}
println("### ## quayBranchName: ${quayBranchName}")
if (pipeConfig.IMAGES_TO_BUILD != null && pipeConfig.IMAGES_TO_BUILD.size > 0) {
for (image_to_build in pipeConfig.IMAGES_TO_BUILD) {
Expand All @@ -362,7 +406,6 @@ spec:
image_to_build,
quayBranchName
)

}
} else {
manifestHelper.editService(
Expand Down
52 changes: 50 additions & 2 deletions vars/performancePipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,64 @@ def call(body) {
kubeLocks << lock
}
stage('WaitForQuayBuild') {
def currentBranchFormatted = pipeConfig['currentBranchFormatted']
if (currentBranchFormatted.length() > 63) {
def newCurrentBranchFormatted = currentBranchFormatted.substring(0,63)
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" is longer than 63 characters. It will will be truncated to \"${newCurrentBranchFormatted}\"")
currentBranchFormatted = newCurrentBranchFormatted
def validImageTagName = currentBranchFormatted ==~ /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/
if (!validImageTagName) {
if (currentBranchFormatted.endsWith("-") || currentBranchFormatted.endsWith(".") || currentBranchFormatted.endsWith("_")) {
newCurrentBranchFormatted = currentBranchFormatted.substring(0,currentBranchFormatted.length()-1)+"0"
validImageTagName = newCurrentBranchFormatted ==~ /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/
if (validImageTagName) {
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" violates validation, it will be changed to \"${newCurrentBranchFormatted}\"")
currentBranchFormatted = newCurrentBranchFormatted
} else {
throw new Exception("currentBranchFormatted \"${currentBranchFormatted}\" violates validation and cannot be used")
}
} else {
throw new Exception("currentBranchFormatted \"${currentBranchFormatted}\" violates validation and cannot be used")
}
} else {
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" passes validation")
}
}
println("### ## currentBranchFormatted: ${currentBranchFormatted}")
quayHelper.waitForBuild(
pipeConfig['quayRegistry'],
pipeConfig['currentBranchFormatted']
currentBranchFormatted
)
}
stage('ModifyManifest') {
def currentBranchFormatted = pipeConfig.serviceTesting.branch
if (currentBranchFormatted.length() > 63) {
def newCurrentBranchFormatted = currentBranchFormatted.substring(0,63)
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" is longer than 63 characters. It will will be truncated to \"${newCurrentBranchFormatted}\"")
currentBranchFormatted = newCurrentBranchFormatted
def validImageTagName = currentBranchFormatted ==~ /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/
if (!validImageTagName) {
if (currentBranchFormatted.endsWith("-") || currentBranchFormatted.endsWith(".") || currentBranchFormatted.endsWith("_")) {
newCurrentBranchFormatted = currentBranchFormatted.substring(0,currentBranchFormatted.length()-1)+"0"
validImageTagName = newCurrentBranchFormatted ==~ /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$/
if (validImageTagName) {
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" violates validation, it will be changed to \"${newCurrentBranchFormatted}\"")
currentBranchFormatted = newCurrentBranchFormatted
} else {
throw new Exception("currentBranchFormatted \"${currentBranchFormatted}\" violates validation and cannot be used")
}
} else {
throw new Exception("currentBranchFormatted \"${currentBranchFormatted}\" violates validation and cannot be used")
}
} else {
println("### ## currentBranchFormatted \"${currentBranchFormatted}\" passes validation")
}
}
println("### ## currentBranchFormatted: ${currentBranchFormatted}")
manifestHelper.editService(
kubeHelper.getHostname(kubectlNamespace),
pipeConfig.serviceTesting.name,
pipeConfig.serviceTesting.branch
currentBranchFormatted
)
}
stage('K8sDeploy') {
Expand Down