Skip to content
Merged
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
37 changes: 32 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.72</version>
<version>5.7</version>
<relativePath />
</parent>

Expand All @@ -43,9 +43,11 @@
<properties>
<revision>1.50</revision>
<changelist>-SNAPSHOT</changelist>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.387</jenkins.baseline>
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<!-- TODO until in BOM -->
<pipeline-model-definition.version>2.2247.va_423189a_7dff</pipeline-model-definition.version>
<useBeta>true</useBeta>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
</properties>

Expand Down Expand Up @@ -99,10 +101,36 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>2543.vfb_1a_5fb_9496d</version>
<version>4228.v0a_71308d905b_</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-api</artifactId>
<version>${pipeline-model-definition.version}</version>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-definition</artifactId>
<version>${pipeline-model-definition.version}</version>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-definition</artifactId>
<version>${pipeline-model-definition.version}</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-extensions</artifactId>
<version>${pipeline-model-definition.version}</version>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-stage-tags-metadata</artifactId>
<version>${pipeline-model-definition.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -115,7 +143,6 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>aws-credentials</artifactId>
<version>231.v08a_59f17d742</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SpotBugs


private static final List<String> FARGATE_RETRYABLE_MESSAGES = ImmutableList.of(
"Timeout waiting for network interface provisioning to complete"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -535,4 +537,14 @@
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;

Check warning on line 547 in src/main/java/com/cloudbees/jenkins/plugins/amazonecs/pipeline/ECSDeclarativeAgent.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 542-547 are not covered by tests
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

private final String label;
private final String name;
private String cloud = DEFAULT_CLOUD;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ECSDeclarativeAgent> {
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
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ECSDeclarativeAgent> {
public class ECSDeclarativeAgentScript extends DeclarativeAgentScript2<ECSDeclarativeAgent> {
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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ignore whitespace)

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
}
}
}
Loading