Search in sources :

Example 6 with GitScm

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

the class GitPluginTest method advanced_clone_test.

@Test
public void advanced_clone_test() {
    final String TEST_INITIAL_COMMIT = "Initial commit";
    final String TEST_COMMIT1_MESSAGE = "First commit";
    final String TEST_COMMIT2_MESSAGE = "Second commit";
    Build b;
    GitRepo repo = buildGitRepo();
    repo.changeAndCommitFoo(TEST_COMMIT1_MESSAGE);
    repo.changeAndCommitFoo(TEST_COMMIT2_MESSAGE);
    repo.transferToDockerContainer(host, port);
    GitScm gitScm = job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME);
    job.addShellStep("git log");
    job.save();
    b = job.startBuild();
    b.shouldSucceed();
    String console = b.getConsole();
    assertThat(console, Matchers.containsRegexp(TEST_INITIAL_COMMIT, Pattern.MULTILINE));
    assertThat(console, Matchers.containsRegexp(TEST_COMMIT1_MESSAGE, Pattern.MULTILINE));
    assertThat(console, Matchers.containsRegexp(TEST_COMMIT2_MESSAGE, Pattern.MULTILINE));
    job.configure();
    GitScm.AdvancedClone behaviour = gitScm.advancedClone().checkShallowClone(true).setNumDepth("2");
    job.save();
    b = job.startBuild();
    b.shouldSucceed();
    console = b.getConsole();
    assertThat(console, not(Matchers.containsRegexp(TEST_INITIAL_COMMIT, Pattern.MULTILINE)));
    assertThat(console, Matchers.containsRegexp(TEST_COMMIT1_MESSAGE, Pattern.MULTILINE));
    assertThat(console, Matchers.containsRegexp(TEST_COMMIT2_MESSAGE, Pattern.MULTILINE));
    job.configure();
    behaviour.setNumDepth("1");
    job.save();
    b = job.startBuild();
    b.shouldSucceed();
    console = b.getConsole();
    assertThat(console, not(Matchers.containsRegexp(TEST_INITIAL_COMMIT, Pattern.MULTILINE)));
    assertThat(console, not(Matchers.containsRegexp(TEST_COMMIT1_MESSAGE, Pattern.MULTILINE)));
    assertThat(console, Matchers.containsRegexp(TEST_COMMIT2_MESSAGE, Pattern.MULTILINE));
}
Also used : GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo) Build(org.jenkinsci.test.acceptance.po.Build) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm) Test(org.junit.Test)

Example 7 with GitScm

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

the class GitPluginTest method advanced_checkout_test.

@Test
public void advanced_checkout_test() {
    final String TEST_COMMIT_MESSAGE = "First commit";
    final String TEST_TIME_OUT = "2";
    Build b;
    GitRepo repo = buildGitRepo();
    repo.changeAndCommitFoo(TEST_COMMIT_MESSAGE);
    repo.transferToDockerContainer(host, port);
    GitScm gitScm = job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME);
    job.save();
    b = job.startBuild();
    b.shouldSucceed();
    String console = b.getConsole();
    String revision = getRevisionFromConsole(console);
    assertThat(console, not(Matchers.containsRegexp("git checkout -f " + revision + " # timeout=" + TEST_TIME_OUT, Pattern.MULTILINE)));
    job.configure();
    gitScm.advancedCheckout().setTimeOut(TEST_TIME_OUT);
    job.save();
    b = job.startBuild();
    b.shouldSucceed();
    console = b.getConsole();
    assertThat(console, Matchers.containsRegexp("git checkout -f " + revision + " # timeout=" + TEST_TIME_OUT, Pattern.MULTILINE));
}
Also used : GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo) Build(org.jenkinsci.test.acceptance.po.Build) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm) Test(org.junit.Test)

Example 8 with GitScm

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

the class MultipleScmsPluginTest method poll_for_changes.

@Test
public void poll_for_changes() {
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    MultipleScms scms = job.useScm(MultipleScms.class);
    GitScm git = scms.addScm(GitScm.class);
    git.url("git://github.com/jenkinsci/acceptance-test-harness.git");
    git.localDir("git-project");
    job.pollScm().schedule("* * * * *");
    job.addShellStep("test -f git-project/pom.xml");
    job.save();
    elasticSleep(70000);
    // We should have some build after 70 seconds
    job.getLastBuild().shouldSucceed().shouldExist();
}
Also used : FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm) MultipleScms(org.jenkinsci.test.acceptance.plugins.multiple_scms.MultipleScms) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 9 with GitScm

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

the class GitPluginNoDockerTest method generateJobWithLocalBranch.

private Job generateJobWithLocalBranch(GIT_IMPL type) {
    Job job = generateJob(type);
    GitScm scm = generateSCM(job).localBranch("selenium_test_branch");
    useJGitIfNeccesary(type, scm);
    return job;
}
Also used : Job(org.jenkinsci.test.acceptance.po.Job) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm)

Example 10 with GitScm

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

the class GitPluginNoDockerTest method generateJobWithRemoteName.

private Job generateJobWithRemoteName(GIT_IMPL type) {
    Job job = generateJob(type);
    GitScm scm = generateSCM(job).remoteName("custom_origin");
    useJGitIfNeccesary(type, scm);
    return job;
}
Also used : Job(org.jenkinsci.test.acceptance.po.Job) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm)

Aggregations

GitScm (org.jenkinsci.test.acceptance.plugins.git.GitScm)10 Job (org.jenkinsci.test.acceptance.po.Job)5 Test (org.junit.Test)4 GitRepo (org.jenkinsci.test.acceptance.plugins.git.GitRepo)3 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)2 MultipleScms (org.jenkinsci.test.acceptance.plugins.multiple_scms.MultipleScms)2 Build (org.jenkinsci.test.acceptance.po.Build)2 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)2 SubversionScm (org.jenkinsci.test.acceptance.plugins.subversion.SubversionScm)1