diff --git a/pom.xml b/pom.xml index 1fc70856..e82355ff 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.jenkins-ci.plugins plugin - 4.72 + 5.7 @@ -43,9 +43,11 @@ 1.50 -SNAPSHOT - - 2.387 + 2.479 ${jenkins.baseline}.3 + + 2.2247.va_423189a_7dff + true jenkinsci/${project.artifactId}-plugin @@ -99,10 +101,36 @@ io.jenkins.tools.bom bom-${jenkins.baseline}.x - 2543.vfb_1a_5fb_9496d + 4228.v0a_71308d905b_ import pom + + org.jenkinsci.plugins + pipeline-model-api + ${pipeline-model-definition.version} + + + org.jenkinsci.plugins + pipeline-model-definition + ${pipeline-model-definition.version} + + + org.jenkinsci.plugins + pipeline-model-definition + ${pipeline-model-definition.version} + tests + + + org.jenkinsci.plugins + pipeline-model-extensions + ${pipeline-model-definition.version} + + + org.jenkinsci.plugins + pipeline-stage-tags-metadata + ${pipeline-model-definition.version} + @@ -115,7 +143,6 @@ org.jenkins-ci.plugins aws-credentials - 231.v08a_59f17d742 org.jenkins-ci.plugins diff --git a/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/ECSLauncher.java b/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/ECSLauncher.java index 10e6e3cf..ab4656b6 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/ECSLauncher.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/ECSLauncher.java @@ -69,7 +69,7 @@ public class ECSLauncher extends JNLPLauncher { private final ECSCloud cloud; private final ECSService ecsService; private boolean launched; - private final int maxAttempts = 2; + private static final int maxAttempts = 2; private static final List FARGATE_RETRYABLE_MESSAGES = ImmutableList.of( "Timeout waiting for network interface provisioning to complete" diff --git a/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgent.java b/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgent.java index 654b364a..30c05759 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgent.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgent.java @@ -5,6 +5,7 @@ import org.jenkinsci.Symbol; import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgent; import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentDescriptor; +import org.jenkinsci.plugins.pipeline.modeldefinition.parser.CompatibilityLoader; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import org.jenkinsci.plugins.variant.OptionalExtension; @@ -20,6 +21,7 @@ import com.cloudbees.jenkins.plugins.amazonecs.ECSTaskTemplate.PortMappingEntry; import com.cloudbees.jenkins.plugins.amazonecs.ECSTaskTemplate.Tag; +import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -535,4 +537,14 @@ public String getDisplayName() { return "ECS Agent"; } } + + @OptionalExtension(requirePlugins = "pipeline-model-extensions") + public static final class Compat implements CompatibilityLoader { + @Override + public URL loadGroovySource(String clazz) { + return "com.cloudbees.jenkins.plugins.amazonecs.pipeline.ECSDeclarativeAgentScript".equals(clazz) + ? ECSDeclarativeAgent.class.getResource("ECSDeclarativeAgentScript-old.groovy") + : null; + } + } } diff --git a/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSTaskTemplateStep.java b/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSTaskTemplateStep.java index 4029b87a..3e8ec4ad 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSTaskTemplateStep.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSTaskTemplateStep.java @@ -47,7 +47,7 @@ public class ECSTaskTemplateStep extends Step implements Serializable { private static final long serialVersionUID = 1L; private static final Logger LOGGER = Logger.getLogger(ECSTaskTemplateStep.class.getName()); - private final String DEFAULT_CLOUD = "cloud-default"; + private static final String DEFAULT_CLOUD = "cloud-default"; private final String label; private final String name; private String cloud = DEFAULT_CLOUD; diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgentScript-old.groovy b/src/main/resources/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgentScript-old.groovy new file mode 100644 index 00000000..cd02ddaa --- /dev/null +++ b/src/main/resources/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgentScript-old.groovy @@ -0,0 +1,60 @@ +/* + * The MIT License + * + * Copyright (c) 2016, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.cloudbees.jenkins.plugins.amazonecs.pipeline + +import hudson.model.Result +import org.jenkinsci.plugins.pipeline.modeldefinition.SyntheticStageNames +import org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript +import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentScript +import org.jenkinsci.plugins.workflow.cps.CpsScript +import org.apache.commons.lang.RandomStringUtils; + + +public class ECSDeclarativeAgentScript extends DeclarativeAgentScript { + public ECSDeclarativeAgentScript(CpsScript s, ECSDeclarativeAgent a) { + super(s, a) + } + + @Override + public Closure run(Closure body) { + return { + try { + if (describable.label == null || describable.label == "") { + String projectName = script.getProperty("currentBuild").projectName.toLowerCase().replaceAll("[^a-z-]", "-") + String number = script.getProperty("currentBuild").number + String label = projectName + "-" + number + "-" + RandomStringUtils.random(5, "bcdfghjklmnpqrstvwxz0123456789"); + describable.setLabel(label) + } + script.ecsTaskTemplate(describable.asArgs) { + script.node(describable.label) { + CheckoutScript.doCheckout(script, describable, null, body).call() + } + } + } catch (Exception e) { + script.getProperty("currentBuild").result = Result.FAILURE + throw e + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgentScript.groovy b/src/main/resources/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgentScript.groovy index cd02ddaa..d2752766 100644 --- a/src/main/resources/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgentScript.groovy +++ b/src/main/resources/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgentScript.groovy @@ -26,35 +26,33 @@ package com.cloudbees.jenkins.plugins.amazonecs.pipeline import hudson.model.Result import org.jenkinsci.plugins.pipeline.modeldefinition.SyntheticStageNames import org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript -import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentScript +import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgentScript2 import org.jenkinsci.plugins.workflow.cps.CpsScript import org.apache.commons.lang.RandomStringUtils; -public class ECSDeclarativeAgentScript extends DeclarativeAgentScript { +public class ECSDeclarativeAgentScript extends DeclarativeAgentScript2 { public ECSDeclarativeAgentScript(CpsScript s, ECSDeclarativeAgent a) { super(s, a) } @Override - public Closure run(Closure body) { - return { - try { - if (describable.label == null || describable.label == "") { - String projectName = script.getProperty("currentBuild").projectName.toLowerCase().replaceAll("[^a-z-]", "-") - String number = script.getProperty("currentBuild").number - String label = projectName + "-" + number + "-" + RandomStringUtils.random(5, "bcdfghjklmnpqrstvwxz0123456789"); - describable.setLabel(label) - } - script.ecsTaskTemplate(describable.asArgs) { - script.node(describable.label) { - CheckoutScript.doCheckout(script, describable, null, body).call() - } + public void run(Closure body) { + try { + if (describable.label == null || describable.label == "") { + String projectName = script.getProperty("currentBuild").projectName.toLowerCase().replaceAll("[^a-z-]", "-") + String number = script.getProperty("currentBuild").number + String label = projectName + "-" + number + "-" + RandomStringUtils.random(5, "bcdfghjklmnpqrstvwxz0123456789"); + describable.setLabel(label) + } + script.ecsTaskTemplate(describable.asArgs) { + script.node(describable.label) { + CheckoutScript.doCheckout2(script, describable, null, body) } - } catch (Exception e) { - script.getProperty("currentBuild").result = Result.FAILURE - throw e } + } catch (Exception e) { + script.getProperty("currentBuild").result = Result.FAILURE + throw e } } } \ No newline at end of file