Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.8</version>
<version>1.10</version>
</extension>
</extensions>
79 changes: 45 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>5.17</version>
<version>5.18</version>
<relativePath />
</parent>
<groupId>io.jenkins.plugins</groupId>
Expand All @@ -16,9 +16,8 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<useBeta>true</useBeta>
<jenkins.baseline>2.504</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
<spotbugs.effort>Max</spotbugs.effort>
<spotbugs.threshold>Low</spotbugs.threshold>
</properties>
Expand Down Expand Up @@ -104,10 +103,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sso</artifactId>
<!-- Not apparently packaged as a plugin, but anyway used only for developer testing: -->
Copy link
Member Author

Choose a reason for hiding this comment

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

<version>2.31.26</version>
<groupId>io.jenkins.plugins.aws-java-sdk2</groupId>
<artifactId>aws-java-sdk2-sso</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -130,36 +127,20 @@
<artifactId>structs</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.test</groupId>
<artifactId>docker-fixtures</artifactId>
<version>200.v22a_e8766731c</version>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>commons-io</groupId> <!-- take version from Jenkins Core -->
<artifactId>commons-io</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -172,6 +153,12 @@
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-slaves</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jdk-tool</artifactId>
Expand Down Expand Up @@ -278,7 +265,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>4710.v016f0a_07e34d</version>
<version>5015.vb_52d36583443</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand All @@ -295,6 +282,30 @@
<artifactId>guice-assistedinject</artifactId>
<version>6.0.0</version>
</dependency>
<!-- TODO https://github.com/jenkinsci/ssh-agents-plugin/pull/607 -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-slaves</artifactId>
<version>3.1069.v30991b_9a_4f68</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>ssh-slaves</artifactId>
<classifier>tests</classifier>
<version>3.1069.v30991b_9a_4f68</version>
</dependency>
<!-- TODO https://github.com/jenkinsci/workflow-api-plugin/pull/416 -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1378.v9b_957b_52b_c74</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<classifier>tests</classifier>
<version>1378.v9b_957b_52b_c74</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class MockBlobStoreTest {

@Test
public void smokes() throws Exception {
ArtifactManagerTest.artifactArchiveAndDelete(j, new JCloudsArtifactManagerFactory(new MockBlobStore()), false, null);
ArtifactManagerTest.artifactStashAndDelete(j, new JCloudsArtifactManagerFactory(new MockBlobStore()), false, null);
ArtifactManagerTest.artifactArchiveAndDelete(j, new JCloudsArtifactManagerFactory(new MockBlobStore()), false);
ArtifactManagerTest.artifactStashAndDelete(j, new JCloudsArtifactManagerFactory(new MockBlobStore()), false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class AbstractIntegrationTest {
protected static final String CONTAINER_PREFIX = "ci/";

@BeforeClass
public static void assumeDocker() throws Exception {
public static void assumeDocker() {
// Beyond just isDockerAvailable, verify the OS:
try {
Assume.assumeThat("expect to run Docker on Linux containers", DockerClientFactory.instance().client().infoCmd().exec().getOsType(), is("linux"));
Expand All @@ -54,7 +54,7 @@ protected static ArtifactManagerFactory getArtifactManagerFactory(Boolean delete

protected static void _artifactArchiveAndDelete(JenkinsRule jenkinsRule) throws Throwable {
createBucketWithAwsClient("artifact-archive-and-delete");
ArtifactManagerTest.artifactArchiveAndDelete(jenkinsRule, getArtifactManagerFactory(true, null), true, null);
ArtifactManagerTest.artifactArchiveAndDelete(jenkinsRule, getArtifactManagerFactory(true, null), true);
}

protected static void createBucketWithAwsClient(String bucketName) throws IOException {
Expand All @@ -66,12 +66,12 @@ protected static void createBucketWithAwsClient(String bucketName) throws IOExce
protected static void _artifactArchive(JenkinsRule jenkinsRule) throws Throwable {
createBucketWithAwsClient("artifact-archive");
assertThat(client().headBucket(HeadBucketRequest.builder().bucket("artifact-archive").build()).sdkHttpResponse().isSuccessful(), is(true));
ArtifactManagerTest.artifactArchive(jenkinsRule, getArtifactManagerFactory(null, null), true, null);
ArtifactManagerTest.artifactArchive(jenkinsRule, getArtifactManagerFactory(null, null), true);
}

protected static void _artifactStashAndDelete(JenkinsRule jenkinsRule) throws Throwable {
createBucketWithAwsClient("artifact-stash-and-delete");
ArtifactManagerTest.artifactStashAndDelete(jenkinsRule, getArtifactManagerFactory(null, true), true, null);
ArtifactManagerTest.artifactStashAndDelete(jenkinsRule, getArtifactManagerFactory(null, true), true);
}

protected static void _canCreateBucket(JenkinsRule r) throws Throwable {
Expand All @@ -84,7 +84,7 @@ protected static void _canCreateBucket(JenkinsRule r) throws Throwable {

protected static void _artifactStash(JenkinsRule jenkinsRule) throws Throwable {
createBucketWithAwsClient("artifact-stash");
ArtifactManagerTest.artifactStash(jenkinsRule, getArtifactManagerFactory(null, null), true, null);
ArtifactManagerTest.artifactStash(jenkinsRule, getArtifactManagerFactory(null, null), true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.*;

import java.io.IOException;
Expand All @@ -41,7 +41,6 @@
import org.apache.commons.io.output.NullOutputStream;
import org.jclouds.rest.internal.InvokeHttpMethod;
import org.jenkinsci.plugins.workflow.ArtifactManagerTest;
import org.jenkinsci.test.acceptance.docker.fixtures.JavaContainer;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
Expand All @@ -52,10 +51,6 @@
import org.jvnet.hudson.test.TestBuilder;

import com.cloudbees.hudson.plugins.folder.Folder;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.cloudbees.plugins.credentials.domains.Domain;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import org.htmlunit.WebResponse;

import hudson.ExtensionList;
Expand All @@ -67,10 +62,9 @@
import hudson.model.FreeStyleProject;
import hudson.model.Item;
import hudson.model.Run;
import hudson.model.Slave;
import hudson.model.TaskListener;
import hudson.plugins.sshslaves.SSHLauncher;
import hudson.remoting.Which;
import hudson.slaves.DumbSlave;
import hudson.tasks.ArtifactArchiver;
import io.jenkins.plugins.aws.global_configuration.CredentialsAwsGlobalConfiguration;
import java.io.Serializable;
Expand Down Expand Up @@ -104,6 +98,7 @@
import org.kohsuke.stapler.DataBoundConstructor;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.services.s3.S3Client;
import test.ssh_agent.OutboundAgent;

public class JCloudsArtifactManagerTest extends S3AbstractTest {

Expand Down Expand Up @@ -133,42 +128,36 @@ protected ArtifactManagerFactory getArtifactManagerFactory(Boolean deleteArtifac

@Test
public void agentPermissions() throws Exception {
var image = ArtifactManagerTest.prepareImage(); // TODO simplify to use Testcontainers directly
assumeNotNull(image);
System.err.println("verifying that while the master can connect to S3, a Dockerized agent cannot");
try (JavaContainer container = image.start(JavaContainer.class).start()) {
SystemCredentialsProvider.getInstance().getDomainCredentialsMap().put(Domain.global(), Collections.singletonList(new UsernamePasswordCredentialsImpl(CredentialsScope.SYSTEM, "test", null, "test", "test")));
DumbSlave agent = new DumbSlave("assumptions", "/home/test/slave", new SSHLauncher(container.ipBound(22), container.port(22), "test"));
Jenkins.get().addNode(agent);
try (var outboundAgent = new OutboundAgent()) {
var connectionDetails = outboundAgent.start();
assumeThat("cannot test this without Docker", connectionDetails, notNullValue());
OutboundAgent.createAgent(j, "remote", connectionDetails);
var agent = (Slave) j.jenkins.getNode("remote");
j.waitOnline(agent);
try {
agent.getChannel().call(new LoadS3Credentials());
fail("did not expect to be able to connect to S3 from a Dockerized agent"); // or AssumptionViolatedException?
} catch (SdkClientException x) {
System.err.println("a Dockerized agent was unable to connect to S3, as expected: " + x);
}
assertThrows("did not expect to be able to connect to S3 from a Dockerized agent", SdkClientException.class, () -> agent.getChannel().call(new LoadS3Credentials()));
}
}

@Test
public void artifactArchive() throws Exception {
// To demo class loading performance: loggerRule.record(SlaveComputer.class, Level.FINEST);
ArtifactManagerTest.artifactArchive(j, getArtifactManagerFactory(null, null), true, null);
ArtifactManagerTest.artifactArchive(j, getArtifactManagerFactory(null, null), true);
}

@Test
public void artifactArchiveAndDelete() throws Exception {
ArtifactManagerTest.artifactArchiveAndDelete(j, getArtifactManagerFactory(true, null), true, null);
ArtifactManagerTest.artifactArchiveAndDelete(j, getArtifactManagerFactory(true, null), true);
}

@Test
public void artifactStash() throws Exception {
ArtifactManagerTest.artifactStash(j, getArtifactManagerFactory(null, null), true, null);
ArtifactManagerTest.artifactStash(j, getArtifactManagerFactory(null, null), true);
}

@Test
public void artifactStashAndDelete() throws Exception {
ArtifactManagerTest.artifactStashAndDelete(j, getArtifactManagerFactory(null, true), true, null);
ArtifactManagerTest.artifactStashAndDelete(j, getArtifactManagerFactory(null, true), true);
}

private static final class LoadS3Credentials extends MasterToSlaveCallable<Void, RuntimeException> {
Expand Down