use of org.jenkinsci.test.acceptance.plugins.git.GitRepo in project acceptance-test-harness by jenkinsci.
the class GitPluginTest method default_strategy_to_choose_build.
@Test
public void default_strategy_to_choose_build() {
final String BRANCH_NAME = "secondBranch";
GitRepo repo = buildGitRepo();
repo.createBranch(BRANCH_NAME);
repo.transferToDockerContainer(host, port);
// Default Strategy for master
job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME).chooseBuildStrategy("Default");
job.save();
Build b = job.startBuild();
b.shouldSucceed();
assertThat(b.getConsole(), Matchers.containsRegexp("Checking out Revision .* \\(refs/remotes/origin/master\\)", Pattern.MULTILINE));
// Default Strategy for secondBranch
job.configure();
job.useScm(GitScm.class).branch(BRANCH_NAME);
job.save();
b = job.startBuild();
b.shouldSucceed();
assertThat(b.getConsole(), Matchers.containsRegexp("Checking out Revision .* \\(origin/" + BRANCH_NAME + "\\)", Pattern.MULTILINE));
// Default Strategy for any branch
job.configure();
job.useScm(GitScm.class).branch("");
job.save();
b = job.startBuild();
b.shouldSucceed();
// 2 branches discovered
assertThat(b.getConsole(), Matchers.containsRegexp("Checking out Revision .* \\(origin/.*, origin/.*\\)", Pattern.MULTILINE));
}
use of org.jenkinsci.test.acceptance.plugins.git.GitRepo in project acceptance-test-harness by jenkinsci.
the class GitPluginTest method buildGitRepo.
private GitRepo buildGitRepo() {
GitRepo repo = new GitRepo();
repo.changeAndCommitFoo("Initial commit");
return repo;
}
use of org.jenkinsci.test.acceptance.plugins.git.GitRepo in project acceptance-test-harness by jenkinsci.
the class GitPluginTest method test_clean_while_checkout.
/**
* Invoked by {@link #clean_after_checkout()} and {@link #clean_before_checkout()}
*
* @param before Select "clean before" or "clean after"
*/
private void test_clean_while_checkout(boolean before) {
GitRepo repo = buildGitRepo();
repo.transferToDockerContainer(host, port);
// configure and build to create untrackedFile.txt
GitScm git = job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME);
if (before) {
git.cleanBeforeCheckout();
} else {
git.cleanAfterCheckout();
}
job.addShellStep("touch untrackedFile.txt");
job.save();
job.startBuild().shouldSucceed();
// configure and build to test if file has been removed
job.configure();
job.removeFirstBuildStep();
job.addShellStep("ls && test ! -f untrackedFile.txt");
job.save();
job.startBuild().shouldSucceed();
}
use of org.jenkinsci.test.acceptance.plugins.git.GitRepo 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));
}
use of org.jenkinsci.test.acceptance.plugins.git.GitRepo 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));
}
Aggregations