From eb65336ed5d45e4be32d7fa9260b150f0cbef59e Mon Sep 17 00:00:00 2001 From: Allan Burdajewicz Date: Sun, 19 May 2024 21:35:47 +1000 Subject: [PATCH] [JENKINS-72622] Rename CloudSet query parameter to avoid conflict (#9198) * [JENKINS-72622] Rename CloudSet query parameter to avoid conflict * [JENKINS-72622] Address SpotBugs warning --- core/src/main/java/jenkins/agents/CloudSet.java | 8 ++++++-- .../src/main/resources/jenkins/agents/CloudSet/_new.jelly | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/jenkins/agents/CloudSet.java b/core/src/main/java/jenkins/agents/CloudSet.java index e69a3f9add3c..addefceb83ff 100644 --- a/core/src/main/java/jenkins/agents/CloudSet.java +++ b/core/src/main/java/jenkins/agents/CloudSet.java @@ -242,9 +242,13 @@ private void handleNewCloudPage(Descriptor descriptor, String name, Stapl */ @POST public synchronized void doDoCreate(StaplerRequest req, StaplerResponse rsp, - @QueryParameter String type) throws IOException, ServletException, Descriptor.FormException { + @QueryParameter String cloudDescriptorName) throws IOException, ServletException, Descriptor.FormException { Jenkins.get().checkPermission(Jenkins.ADMINISTER); - Cloud cloud = Cloud.all().find(type).newInstance(req, req.getSubmittedForm()); + Descriptor cloudDescriptor = Cloud.all().findByName(cloudDescriptorName); + if (cloudDescriptor == null) { + throw new Failure(String.format("No cloud type ā€˜%sā€™ is known", cloudDescriptorName)); + } + Cloud cloud = cloudDescriptor.newInstance(req, req.getSubmittedForm()); if (!Jenkins.get().clouds.add(cloud)) { LOGGER.log(Level.WARNING, () -> "Creating duplicate cloud name " + cloud.name + ". Plugin " + Jenkins.get().getPluginManager().whichPlugin(cloud.getClass()) + " should be updated to support user provided name."); } diff --git a/core/src/main/resources/jenkins/agents/CloudSet/_new.jelly b/core/src/main/resources/jenkins/agents/CloudSet/_new.jelly index 3ea4d00d6acc..bc882a546e98 100644 --- a/core/src/main/resources/jenkins/agents/CloudSet/_new.jelly +++ b/core/src/main/resources/jenkins/agents/CloudSet/_new.jelly @@ -37,7 +37,7 @@ THE SOFTWARE. - +