Search in sources :

Example 51 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method should_delete_removed_views.

/**
 * Verifies whether a previously generated view will be deleted if it
 * is not referenced anymore.
 */
@Test
public void should_delete_removed_views() {
    FreeStyleJob seedJob = executeRemovedViewAction(JobDslRemovedViewAction.DELETE);
    Build build = seedJob.scheduleBuild().shouldSucceed();
    Pattern expected = Pattern.compile("Unreferenced views:(\\s*)GeneratedView[{]name='Old_View'}(\\s*)Removed views:(\\s*)GeneratedView[{]name='Old_View'}");
    assertThat(build.getConsole(), containsRegexp(expected));
    ListView oldView = getView("Old_View");
    assertThat(oldView, pageObjectDoesNotExist());
}
Also used : Pattern(java.util.regex.Pattern) ListView(org.jenkinsci.test.acceptance.po.ListView) Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 52 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class GitPluginTest method calculate_changelog.

@Test
public void calculate_changelog() {
    final URL changesUrl;
    final String TEST_COMMIT_MESSAGE = "Second commit";
    Build b;
    GitRepo repo = buildGitRepo();
    repo.createBranch("testBranch");
    repo.changeAndCommitFoo(TEST_COMMIT_MESSAGE);
    repo.transferToDockerContainer(host, port);
    job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME).calculateChangelog("origin", "testBranch");
    job.save();
    b = job.startBuild();
    b.shouldSucceed();
    changesUrl = b.url("changes");
    assertThat(b.getConsole(), Matchers.containsRegexp("Using 'Changelog to branch' strategy.", Pattern.MULTILINE));
    assertThat(visit(changesUrl).getPageSource(), Matchers.containsRegexp(TEST_COMMIT_MESSAGE, Pattern.MULTILINE));
}
Also used : GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo) Build(org.jenkinsci.test.acceptance.po.Build) URL(java.net.URL) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm) Test(org.junit.Test)

Example 53 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class GitPluginTest method create_tag_for_build.

@Test
public void create_tag_for_build() {
    GitRepo repo = buildGitRepo();
    repo.transferToDockerContainer(host, port);
    job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME).customNameAndMail("fake", "fake@mail.com").createTagForBuild();
    job.addShellStep("git tag -n1");
    job.save();
    Build b = job.startBuild();
    b.shouldSucceed();
    assertThat(b.getConsole(), Matchers.containsRegexp("jenkins-" + job.name + "-1 Jenkins Build #1", Pattern.MULTILINE));
}
Also used : GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo) Build(org.jenkinsci.test.acceptance.po.Build) Test(org.junit.Test)

Example 54 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class GitPluginTest method commit_author_in_changelog_test.

@Test
public void commit_author_in_changelog_test() {
    URL changesUrl;
    final String TEST_COMMIT_MESSAGE = "Second commit";
    final String BRANCH_NAME = "testBranch";
    final String TEST_FILE = "foo_test_branch";
    Build b;
    GitRepo repo = buildGitRepo();
    repo.createBranch(BRANCH_NAME);
    repo.touch(TEST_FILE);
    repo.git("add", TEST_FILE);
    repo.git("commit", "-m", TEST_COMMIT_MESSAGE, "--author", "New-Author <other-email@example.org>");
    repo.transferToDockerContainer(host, port);
    job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME).calculateChangelog("origin", BRANCH_NAME);
    job.save();
    b = job.startBuild();
    b.shouldSucceed();
    changesUrl = b.url("changes");
    assertThat(visit(changesUrl).getPageSource(), Matchers.containsRegexp("/user/jenkins-ath/", Pattern.MULTILINE));
    job.configure();
    job.useScm(GitScm.class).commitAuthorInChangelog();
    job.save();
    b = job.startBuild();
    b.shouldSucceed();
    changesUrl = b.url("changes");
    assertThat(visit(changesUrl).getPageSource(), Matchers.containsRegexp("/user/other-email/", Pattern.MULTILINE));
}
Also used : GitRepo(org.jenkinsci.test.acceptance.plugins.git.GitRepo) Build(org.jenkinsci.test.acceptance.po.Build) URL(java.net.URL) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm) Test(org.junit.Test)

Example 55 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class GitPluginTest method custom_scm_name.

@Test
public void custom_scm_name() {
    final String SCM_NAME = "halligalli";
    GitRepo repo = buildGitRepo();
    repo.transferToDockerContainer(host, port);
    job.useScm(GitScm.class).url(repoUrl).credentials(USERNAME).customScmName(SCM_NAME);
    job.save();
    Build b = job.startBuild();
    b.shouldSucceed();
    // Git plugin 4.0 switched from <b> to <strong>. Accept either bold or strong.
    assertThat(visit(b.url("git")).getPageSource(), Matchers.containsRegexp("<[^>]+>SCM:?</[^>]+>:? " + SCM_NAME, 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)

Aggregations

Build (org.jenkinsci.test.acceptance.po.Build)175 Test (org.junit.Test)157 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)113 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)101 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)40 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)22 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)20 Issue (org.jvnet.hudson.test.Issue)18 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 GitRepo (org.jenkinsci.test.acceptance.plugins.git.GitRepo)13 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)13 Pattern (java.util.regex.Pattern)11 Job (org.jenkinsci.test.acceptance.po.Job)11 SmokeTest (org.jenkinsci.test.acceptance.junit.SmokeTest)9 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)9 GitScm (org.jenkinsci.test.acceptance.plugins.git.GitScm)9 Matchers.containsString (org.hamcrest.Matchers.containsString)8 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)8 MavenModuleSet (org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet)7 IOException (java.io.IOException)6