Skip to content

Commit

Permalink
Improve architecture validation
Browse files Browse the repository at this point in the history
  • Loading branch information
steelhead31 committed Jan 16, 2025
1 parent 49b3b09 commit c6cb254
Showing 1 changed file with 35 additions and 16 deletions.
51 changes: 35 additions & 16 deletions linux_new/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -320,22 +320,41 @@ pipeline {
error("Pipeline Skipped Due To Triggered For Neither Alpine Or Linux")
}

// Figure Out Which Arch This Run Is For
if (params.ARTIFACTS_TO_COPY.contains('aarch64')) {
arch = "aarch64"
} else if (params.ARTIFACTS_TO_COPY.contains('x64')) {
arch = "x64"
} else if (params.ARTIFACTS_TO_COPY.contains('s390x')) {
arch = "s390x"
} else if (params.ARTIFACTS_TO_COPY.contains('arm')) {
arch = "arm"
} else if (params.ARTIFACTS_TO_COPY.contains('ppc64le')) {
arch = "ppc64le"
} else if (params.ARTIFACTS_TO_COPY.contains('riscv64')) {
arch = "riscv64"
} else {
printlin "WARNING: The Artifacts Specified Are For An Unsupported Architecture"
error("The Artifacts Are For An Unsupported Architecture")
// // Figure Out Which Arch This Run Is For

// if (params.ARTIFACTS_TO_COPY.contains('aarch64')) {
// arch = "aarch64"
// } else if (params.ARTIFACTS_TO_COPY.contains('x64')) {
// arch = "x64"
// } else if (params.ARTIFACTS_TO_COPY.contains('s390x')) {
// arch = "s390x"
// } else if (params.ARTIFACTS_TO_COPY.contains('arm')) {
// arch = "arm"
// } else if (params.ARTIFACTS_TO_COPY.contains('ppc64le')) {
// arch = "ppc64le"
// } else if (params.ARTIFACTS_TO_COPY.contains('riscv64')) {
// arch = "riscv64"
// } else {
// printlin "WARNING: The Artifacts Specified Are For An Unsupported Architecture"
// error("The Artifacts Are For An Unsupported Architecture")
// }

// Valid architectures
def validArchs = ['aarch64', 'x64', 's390x', 'arm', 'ppc64le', 'riscv64']

// Extract architectures from the parameter
def specifiedArchs = params.ARTIFACTS_TO_COPY.tokenize(',') // Assuming it's comma-separated

// Find valid and invalid architectures
def matchedArchs = specifiedArchs.findAll { it in validArchs }
def invalidArchs = specifiedArchs - matchedArchs

// Validate the input
if (matchedArchs.size() == 1 && invalidArchs.isEmpty()) {
arch = matchedArchs[0]
} else if (matchedArchs.isEmpty() || !invalidArchs.isEmpty() || matchedArchs.size() > 1) {
println "WARNING: Invalid or multiple architectures specified: ${specifiedArchs}"
error("The Artifacts contain unsupported or multiple architectures: ${specifiedArchs}")
}

// Derive Node To Build Packages On
Expand Down

0 comments on commit c6cb254

Please sign in to comment.