From c6cb254b24431d148540c04f5e3104b1fd73f00e Mon Sep 17 00:00:00 2001 From: Scott Fryer Date: Thu, 16 Jan 2025 10:29:50 +0000 Subject: [PATCH] Improve architecture validation --- linux_new/Jenkinsfile | 51 +++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/linux_new/Jenkinsfile b/linux_new/Jenkinsfile index 6d7a3a790..a377669aa 100644 --- a/linux_new/Jenkinsfile +++ b/linux_new/Jenkinsfile @@ -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