From cb12ae4a23e861782398f88232a9d9a6c02fbb5f Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Thu, 27 Jun 2024 13:25:05 +0200 Subject: [PATCH 1/2] Update to 2.426.x baseline --- Jenkinsfile | 16 ++++++++-------- README.md | 2 +- pom.xml | 11 ++++------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fffa9ae..9bdbcc7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,10 @@ -#!groovy -def recentLTS = '2.414.2' +/* + See the documentation for more options: + https://github.com/jenkins-infra/pipeline-library/ +*/ buildPlugin( - // Container agents start faster and are easier to administer - useContainerAgent: true, + useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests configurations: [ - [platform: 'linux', jdk: '21'], - [platform: 'windows', jdk: '17', jenkins: recentLTS], - ] -) + [platform: 'linux', jdk: 21], + [platform: 'windows', jdk: 17], +]) diff --git a/README.md b/README.md index 2d1a4b5..9c85e31 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Jenkins Plugin Installs](https://img.shields.io/jenkins/plugin/i/amazon-ecr.svg?color=blue)](https://plugins.jenkins.io/amazon-ecr) [![Build Status](https://ci.jenkins.io/buildStatus/icon?job=Plugins%2Famazon-ecr-plugin%2Fmain)](https://ci.jenkins.io/job/Plugins/job/amazon-ecr-plugin/job/main/) [![GitHub license](https://img.shields.io/github/license/jenkinsci/amazon-ecr-plugin.svg)](https://github.com/jenkinsci/amazon-ecr-plugin/blob/main/LICENSE.txt) -[![Maintenance](https://img.shields.io/maintenance/yes/2023.svg)]() +[![Maintenance](https://img.shields.io/maintenance/yes/2024.svg)]() This plugin offers integration with [Amazon Container Registry (ECR)](https://aws.amazon.com/ecr/) as a [DockerRegistryToken] source to convert diff --git a/pom.xml b/pom.xml index 547118f..089770a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.jenkins-ci.plugins plugin - 4.74 + 4.83 com.cloudbees.jenkins.plugins @@ -61,7 +61,7 @@ 1 999999-SNAPSHOT jenkinsci/amazon-ecr-plugin - 2.361.4 + 2.426.3 false @@ -69,8 +69,8 @@ io.jenkins.tools.bom - bom-2.361.x - 2102.v854b_fec19c92 + bom-2.426.x + 3143.v347db_7c6db_6e pom import @@ -80,7 +80,6 @@ org.jenkins-ci.plugins aws-credentials - 191.vcb_f183ce58b_9 org.jenkins-ci.plugins @@ -89,12 +88,10 @@ org.jenkins-ci.plugins docker-commons - 1.21 org.jenkins-ci.plugins.aws-java-sdk aws-java-sdk-ecr - 1.12.287-357.vf82d85a_6eefd From c45fcef0d1a25b3b0b633fcbadab2b254d525dd5 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Thu, 27 Jun 2024 13:31:19 +0200 Subject: [PATCH 2/2] Clean up some deprecations --- .../AmazonECSRegistryCredential.java | 26 +++++++++--------- .../AmazonECSRegistryCredentialsProvider.java | 27 ++++++++++--------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredential.java b/src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredential.java index 7e1070f..31a6b3f 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredential.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredential.java @@ -39,15 +39,14 @@ import com.cloudbees.plugins.credentials.CredentialsScope; import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.model.ItemGroup; import hudson.security.ACL; import hudson.util.Secret; -import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; import jenkins.model.Jenkins; import org.apache.commons.lang.StringUtils; @@ -66,13 +65,13 @@ public class AmazonECSRegistryCredential extends BaseStandardCredentials private final ItemGroup itemGroup; public AmazonECSRegistryCredential( - CredentialsScope scope, @Nonnull String credentialsId, String description, ItemGroup itemGroup) { - this(scope, credentialsId, Regions.US_EAST_1, description, (ItemGroup) itemGroup); + CredentialsScope scope, @NonNull String credentialsId, String description, ItemGroup itemGroup) { + this(scope, credentialsId, Regions.US_EAST_1, description, itemGroup); } public AmazonECSRegistryCredential( @CheckForNull CredentialsScope scope, - @Nonnull String credentialsId, + @NonNull String credentialsId, Regions region, String description, ItemGroup itemGroup) { @@ -88,7 +87,7 @@ public AmazonECSRegistryCredential( this.itemGroup = itemGroup; } - @Nonnull + @NonNull public String getCredentialsId() { return credentialsId; } @@ -97,8 +96,8 @@ public String getCredentialsId() { LOG.log(Level.FINE, "Looking for Amazon web credentials ID: {0} Region: {1}", new Object[] { this.credentialsId, this.region }); - List credentials = CredentialsProvider.lookupCredentials( - AmazonWebServicesCredentials.class, itemGroup, ACL.SYSTEM, Collections.EMPTY_LIST); + List credentials = CredentialsProvider.lookupCredentialsInItemGroup( + AmazonWebServicesCredentials.class, itemGroup, ACL.SYSTEM2); if (LOG.isLoggable(Level.FINEST)) { String fullStackTrace = org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(new Throwable()); @@ -120,14 +119,15 @@ public String getCredentialsId() { return null; } - @Nonnull + @NonNull + @Override public String getDescription() { String description = super.getDescription(); LOG.finest(description); return description; } - @Nonnull + @NonNull @Override public Secret getPassword() { final AmazonWebServicesCredentials credentials = getCredentials(); @@ -167,13 +167,13 @@ public Secret getPassword() { return Secret.fromString(authorizationData.get(0).getAuthorizationToken()); } - @Nonnull + @NonNull @Override public String getUsername() { return "AWS"; } - @Nonnull + @NonNull public String getEmail() { return "nobody@example.com"; } diff --git a/src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredentialsProvider.java b/src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredentialsProvider.java index d399a57..efbbfb4 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredentialsProvider.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/amazonecr/AmazonECSRegistryCredentialsProvider.java @@ -29,17 +29,17 @@ import com.cloudbees.jenkins.plugins.awscredentials.AmazonWebServicesCredentials; import com.cloudbees.plugins.credentials.Credentials; import com.cloudbees.plugins.credentials.CredentialsProvider; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; +import com.cloudbees.plugins.credentials.domains.DomainRequirement; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import hudson.Extension; import hudson.model.ItemGroup; import java.util.Collections; +import java.util.LinkedList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import org.acegisecurity.Authentication; +import org.springframework.security.core.Authentication; /** * This class automatically wraps existing {@link AmazonWebServicesCredentials} instances into a @@ -50,19 +50,22 @@ public class AmazonECSRegistryCredentialsProvider extends CredentialsProvider { private static final Logger LOG = Logger.getLogger(AmazonECSRegistryCredentialsProvider.class.getName()); - @Nonnull + @NonNull @Override - public List getCredentials( - @Nonnull Class type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication) { + public List getCredentialsInItemGroup( + @NonNull Class type, + @Nullable ItemGroup itemGroup, + @Nullable Authentication authentication, + @NonNull List domainRequirements) { if (!type.isAssignableFrom(AmazonECSRegistryCredential.class)) { - return ImmutableList.of(); + return Collections.emptyList(); } - List derived = Lists.newLinkedList(); + List derived = new LinkedList<>(); - final List list = lookupCredentials( - AmazonWebServicesCredentials.class, itemGroup, authentication, Collections.EMPTY_LIST); + final List list = lookupCredentialsInItemGroup( + AmazonWebServicesCredentials.class, itemGroup, authentication, domainRequirements); for (AmazonWebServicesCredentials credentials : list) { LOG.log(