diff --git a/pom.xml b/pom.xml index d60932d..be31cf8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 4.80 + 6.2116.v7501b_67dc517 de.taimos @@ -23,7 +23,7 @@ io.jenkins.tools.bom bom-${jenkins.baseline}.x - 2928.ved44ea_84e034 + 5054.v620b_5d2b_d5e6 import pom @@ -79,9 +79,10 @@ 1.46 -SNAPSHOT - 2.414 + 2.479 ${jenkins.baseline}.3 jenkinsci/${project.artifactId}-plugin + false diff --git a/src/main/java/de/taimos/pipeline/aws/AWSClientFactory.java b/src/main/java/de/taimos/pipeline/aws/AWSClientFactory.java index abb4fd4..dc91024 100644 --- a/src/main/java/de/taimos/pipeline/aws/AWSClientFactory.java +++ b/src/main/java/de/taimos/pipeline/aws/AWSClientFactory.java @@ -35,7 +35,6 @@ import hudson.EnvVars; import hudson.FilePath; import hudson.model.TaskListener; -import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -90,8 +89,9 @@ public static , T> T create(B clientBuilder if (clientBuilder == null) { throw new IllegalArgumentException("ClientBuilder must not be null"); } - if (StringUtils.isNotBlank(vars.get(AWS_ENDPOINT_URL))) { - clientBuilder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(vars.get(AWS_ENDPOINT_URL), vars.get(AWS_REGION))); + String endpointUrl = vars.get(AWS_ENDPOINT_URL); + if (endpointUrl != null && !endpointUrl.isBlank()) { + clientBuilder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpointUrl, vars.get(AWS_REGION))); } else { clientBuilder.setRegion(AWSClientFactory.getRegion(vars).getName()); } diff --git a/src/main/java/de/taimos/pipeline/aws/cloudformation/CloudFormationStack.java b/src/main/java/de/taimos/pipeline/aws/cloudformation/CloudFormationStack.java index f2fda19..89c22b5 100644 --- a/src/main/java/de/taimos/pipeline/aws/cloudformation/CloudFormationStack.java +++ b/src/main/java/de/taimos/pipeline/aws/cloudformation/CloudFormationStack.java @@ -129,7 +129,7 @@ public Map create(String templateBody, String templateUrl, Colle CreateStackRequest req = new CreateStackRequest(); req.withStackName(this.stack).withCapabilities(Capability.CAPABILITY_IAM, Capability.CAPABILITY_NAMED_IAM, Capability.CAPABILITY_AUTO_EXPAND).withEnableTerminationProtection(enableTerminationProtection); req.withTemplateBody(templateBody).withTemplateURL(templateUrl).withParameters(params).withTags(tags).withNotificationARNs(notificationARNs) - .withTimeoutInMinutes(pollConfiguration.getTimeout() == null ? null : (int) pollConfiguration.getTimeout().toMinutes()) + .withTimeoutInMinutes((int) pollConfiguration.getTimeout().toMinutes()) .withRoleARN(roleArn) .withOnFailure(OnFailure.valueOf(onFailure)); this.client.createStack(req); diff --git a/src/main/java/de/taimos/pipeline/aws/cloudformation/EventPrinter.java b/src/main/java/de/taimos/pipeline/aws/cloudformation/EventPrinter.java index ca2d813..08e086c 100644 --- a/src/main/java/de/taimos/pipeline/aws/cloudformation/EventPrinter.java +++ b/src/main/java/de/taimos/pipeline/aws/cloudformation/EventPrinter.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.concurrent.ExecutionException; -import org.apache.commons.lang.StringUtils; import org.apache.http.concurrent.BasicFuture; import com.amazonaws.AmazonWebServiceRequest; @@ -50,16 +49,6 @@ import de.taimos.pipeline.aws.cloudformation.utils.TimeOutRetryStrategy; import hudson.model.TaskListener; -import org.apache.commons.lang.StringUtils; -import org.apache.http.concurrent.BasicFuture; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.concurrent.ExecutionException; - class EventPrinter { private static final int DEFAULT_TIMEOUT_IN_MINUTES = 60; @@ -173,7 +162,7 @@ private void printEvent(SimpleDateFormat sdf, StackEvent event) { } private void printLine() { - this.listener.getLogger().println(StringUtils.repeat("-", 231)); + this.listener.getLogger().println("-".repeat(231)); } private void printStackName(String stackName) { diff --git a/src/main/java/de/taimos/pipeline/aws/cloudformation/PollConfiguration.java b/src/main/java/de/taimos/pipeline/aws/cloudformation/PollConfiguration.java index 8d5e086..0d448c6 100644 --- a/src/main/java/de/taimos/pipeline/aws/cloudformation/PollConfiguration.java +++ b/src/main/java/de/taimos/pipeline/aws/cloudformation/PollConfiguration.java @@ -1,13 +1,14 @@ package de.taimos.pipeline.aws.cloudformation; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import lombok.Builder; import lombok.NonNull; import lombok.Value; - import java.time.Duration; @Value @Builder(toBuilder = true) +@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") // Lombok @NonNull check public class PollConfiguration { public static final PollConfiguration DEFAULT = builder() diff --git a/src/main/java/de/taimos/pipeline/aws/code/deploy/CreateDeployStep.java b/src/main/java/de/taimos/pipeline/aws/code/deploy/CreateDeployStep.java index f699881..de96953 100644 --- a/src/main/java/de/taimos/pipeline/aws/code/deploy/CreateDeployStep.java +++ b/src/main/java/de/taimos/pipeline/aws/code/deploy/CreateDeployStep.java @@ -17,7 +17,6 @@ import hudson.Extension; import hudson.model.TaskListener; import lombok.Getter; -import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.workflow.steps.Step; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.jenkinsci.plugins.workflow.steps.StepDescriptor; @@ -186,7 +185,7 @@ private FileExistsBehavior getFileExistsBehavior(String fileExistsBehavior) { if (isEcsOrLambdaDeployment()) { return null; } - if (StringUtils.isEmpty(fileExistsBehavior)) { + if (fileExistsBehavior == null || fileExistsBehavior.isEmpty()) { return FileExistsBehavior.DISALLOW; } return FileExistsBehavior.fromValue(fileExistsBehavior); @@ -214,7 +213,7 @@ private boolean isEcsOrLambdaDeployment() { } private RevisionLocation getRevisionLocation() { - if (StringUtils.isNotEmpty(step.getS3Bucket())) { + if (step.getS3Bucket() != null && !step.getS3Bucket().isEmpty()) { final S3Location s3Location = new S3Location().withBucket(step.getS3Bucket()) .withKey(step.getS3Key()) .withBundleType(step.getS3BundleType()); diff --git a/src/test/java/de/taimos/pipeline/aws/RoleSessionNameBuilderTest.java b/src/test/java/de/taimos/pipeline/aws/RoleSessionNameBuilderTest.java index 6b9e5bf..e768ceb 100644 --- a/src/test/java/de/taimos/pipeline/aws/RoleSessionNameBuilderTest.java +++ b/src/test/java/de/taimos/pipeline/aws/RoleSessionNameBuilderTest.java @@ -39,7 +39,7 @@ public void shortNamesAreNotStripped() { @Test public void nameLongerThanAWSLimitAreStripped() { - String jobName = org.apache.commons.lang.StringUtils.repeat("s", 64); + String jobName = "s".repeat(64); String buildNumber = "123"; final RoleSessionNameBuilder roleSessionNameBuilder = RoleSessionNameBuilder.withJobName(jobName) .withBuildNumber(buildNumber); @@ -49,7 +49,7 @@ public void nameLongerThanAWSLimitAreStripped() { @Test public void nameEqualToAWSLimitAreStripped() { - String jobName = org.apache.commons.lang.StringUtils.repeat("s", 52); + String jobName = "s".repeat(52); String buildNumber = "123"; final RoleSessionNameBuilder roleSessionNameBuilder = RoleSessionNameBuilder.withJobName(jobName) .withBuildNumber(buildNumber);