Search in sources :

Example 16 with GitRepo

use of org.jenkinsci.test.acceptance.plugins.git.GitRepo in project acceptance-test-harness by jenkinsci.

the class GitPluginTest method sparse_checkout.

@Test
public void sparse_checkout() {
    final String SUB_DIR = "testDir";
    final String TEST_FILE = "testFile.txt";
    GitRepo repo = buildGitRepo();
    repo.touch(SUB_DIR + "/" + TEST_FILE);
    repo.touch(TEST_FILE);
    repo.addFilesIn(getClass().getResource("."));
    repo.commit("Added two test files.");
    repo.transferToDockerContainer(host, port);
    job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME).sparseCheckout().addPath(SUB_DIR);
    job.addShellStep("test ! -f " + TEST_FILE + " && test -f " + SUB_DIR + "/" + TEST_FILE);
    job.save();
    Build b = job.startBuild();
    b.shouldSucceed();
}
Also used : GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo) Build(org.jenkinsci.test.acceptance.po.Build) Test(org.junit.Test)

Example 17 with GitRepo

use of org.jenkinsci.test.acceptance.plugins.git.GitRepo in project acceptance-test-harness by jenkinsci.

the class WorkflowPluginTest method createGitRepositoryInDockerContainer.

private String createGitRepositoryInDockerContainer() throws IOException {
    try (GitRepo repo = new GitRepo()) {
        repo.addFilesIn(getClass().getResource("/pipelines/hello-world"));
        repo.commit("Initial commit.");
        GitContainer container = gitServer.get();
        repo.transferToDockerContainer(container.host(), container.port());
        return container.getRepoUrl();
    }
}
Also used : GitContainer(org.jenkinsci.test.acceptance.docker.fixtures.GitContainer) GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo)

Example 18 with GitRepo

use of org.jenkinsci.test.acceptance.plugins.git.GitRepo in project acceptance-test-harness by jenkinsci.

the class GitPluginTest method ancestry_strategy_to_choose_build.

@Test
public void ancestry_strategy_to_choose_build() {
    final String TEST_BRANCH = "testBranch";
    GitRepo repo = buildGitRepo();
    repo.createBranch(TEST_BRANCH);
    repo.changeAndCommitFoo("Commit1 on master");
    repo.checkout(TEST_BRANCH);
    repo.changeAndCommitFoo("commit1 on " + TEST_BRANCH);
    String sha1 = repo.getLastSha1();
    repo.changeAndCommitFoo("commit2 on " + TEST_BRANCH);
    repo.transferToDockerContainer(host, port);
    job.useScm(GitScm.class).url(repoUrl).branch("").credentials(USERNAME).chooseBuildStrategy("Ancestry", 1, sha1);
    job.save();
    Build b = job.startBuild();
    b.shouldSucceed();
    // TODO Multiple selected branches create multiple builds, these should also be verified
    assertThat(b.getConsole(), Matchers.containsRegexp("Checking out Revision .* \\(origin/" + TEST_BRANCH + "\\)", Pattern.MULTILINE));
}
Also used : GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo) Build(org.jenkinsci.test.acceptance.po.Build) Test(org.junit.Test)

Example 19 with GitRepo

use of org.jenkinsci.test.acceptance.plugins.git.GitRepo in project acceptance-test-harness by jenkinsci.

the class AnalysisCollectorPluginTest method createGitRepositoryInDockerContainer.

private String createGitRepositoryInDockerContainer() {
    GitRepo repo = new GitRepo();
    repo.addFilesIn(ANALYSIS_COLLECTOR_PLUGIN_RESOURCES);
    repo.commit("Initial commit in master");
    repo.createBranch("branch");
    GitContainer container = gitServer.get();
    repo.transferToDockerContainer(container.host(), container.port());
    return container.getRepoUrl();
}
Also used : GitContainer(org.jenkinsci.test.acceptance.docker.fixtures.GitContainer) GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo)

Aggregations

GitRepo (org.jenkinsci.test.acceptance.plugins.git.GitRepo)19 Test (org.junit.Test)14 Build (org.jenkinsci.test.acceptance.po.Build)12 GitScm (org.jenkinsci.test.acceptance.plugins.git.GitScm)11 GitContainer (org.jenkinsci.test.acceptance.docker.fixtures.GitContainer)4 URL (java.net.URL)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1 DockerAgentContainer (org.jenkinsci.test.acceptance.docker.fixtures.DockerAgentContainer)1 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)1 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)1 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)1 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)1 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)1 SshSlaveLauncher (org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher)1 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)1 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)1 CommandBuilder (org.jenkinsci.utils.process.CommandBuilder)1 Category (org.junit.experimental.categories.Category)1 Issue (org.jvnet.hudson.test.Issue)1