Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-27152] Integration test for Docker Pipeline, Git, and SSH Ag…
…ent plugins.
  • Loading branch information
jglick committed Feb 29, 2016
1 parent 5d57dd4 commit ef45669
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/test/java/plugins/WorkflowPluginTest.java
Expand Up @@ -28,25 +28,35 @@
import javax.inject.Inject;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.jenkinsci.test.acceptance.Matchers.hasContent;
import org.jenkinsci.test.acceptance.docker.DockerContainerHolder;
import org.jenkinsci.test.acceptance.docker.fixtures.GitContainer;
import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
import org.jenkinsci.test.acceptance.junit.Native;
import org.jenkinsci.test.acceptance.junit.Wait;
import org.jenkinsci.test.acceptance.junit.WithCredentials;
import org.jenkinsci.test.acceptance.junit.WithDocker;
import org.jenkinsci.test.acceptance.junit.WithPlugins;
import org.jenkinsci.test.acceptance.plugins.git.GitRepo;
import org.jenkinsci.test.acceptance.plugins.maven.MavenInstallation;
import org.jenkinsci.test.acceptance.po.Artifact;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.DumbSlave;
import org.jenkinsci.test.acceptance.po.WorkflowJob;
import org.jenkinsci.test.acceptance.slave.SlaveController;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.Issue;

/**
* Roughly follows <a href="https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md">the tutorial</a>.
*/
public class WorkflowPluginTest extends AbstractJUnitTest {

@Inject private SlaveController slaveController;
@Inject DockerContainerHolder<GitContainer> gitServer;
@Rule public TemporaryFolder tmp = new TemporaryFolder();

@WithPlugins("workflow-aggregator@1.1")
@Test public void helloWorld() throws Exception {
Expand Down Expand Up @@ -158,4 +168,31 @@ public class WorkflowPluginTest extends AbstractJUnitTest {
build.shouldContainsConsoleOutput("divided into 3 sets");
}

@WithDocker
@WithPlugins({"workflow-aggregator@1.14", "docker-workflow@1.14-SNAPSHOT", "git", "ssh-agent@1.10-SNAPSHOT"})
@WithCredentials(credentialType=WithCredentials.SSH_USERNAME_PRIVATE_KEY, values={"git", "/org/jenkinsci/test/acceptance/docker/fixtures/GitContainer/unsafe"}, id="gitcreds")
@Issue("JENKINS-27152")
@Test public void sshGitInsideDocker() throws Exception {
// Pending https://github.com/jenkinsci/docker-workflow-plugin/pull/31 (and additional APIs in DockerFixture etc.)
// it is not possible to run this on a bind-mounted Docker slave, so we cannot verify that paths are local to the slave.
GitContainer container = gitServer.get();
String host = container.host();
int port = container.port();
GitRepo repo = new GitRepo();
repo.commit("Initial commit");
repo.transferToDockerContainer(host, port);
WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
job.script.set(
"node {ws('" + tmp.getRoot() + "') {\n" + // TODO UNIX_PATH_MAX workaround
" docker.image('cloudbees/java-build-tools').inside {\n" +
" git url: '" + container.getRepoUrlInsideDocker() + "', credentialsId: 'gitcreds'\n" +
" sh 'mkdir ~/.ssh && echo StrictHostKeyChecking no > ~/.ssh/config'\n" +
" sshagent(['gitcreds']) {sh 'ls -l $SSH_AUTH_SOCK && git pull origin master'}\n" +
" }\n" +
"}}");
job.sandbox.check();
job.save();
job.startBuild().shouldSucceed();
}

}

0 comments on commit ef45669

Please sign in to comment.