Search in sources :

Example 1 with GradleStep

use of org.jenkinsci.test.acceptance.plugins.gradle.GradleStep in project acceptance-test-harness by jenkinsci.

the class GradlePluginTest method run_gradle_user_home_workspace.

/**
 * Verify the execution of gradle build script with gradle installation files in the job workspace.
 */
@Test
public void run_gradle_user_home_workspace() {
    GradleInstallation.installGradle(jenkins);
    final FreeStyleJob job = jenkins.jobs.create();
    job.copyResource(resource(GRADLE_SCRIPT), "build.gradle");
    final GradleStep step = job.addBuildStep(GradleStep.class);
    step.setTasks(HELLO.getName());
    step.setVersion(GradleInstallation.DEFAULT);
    step.setForceGradleHomeToUseWorkspace();
    job.save();
    job.startBuild().shouldSucceed();
    assertThat(job, Workspace.workspaceContains("caches"));
}
Also used : GradleStep(org.jenkinsci.test.acceptance.plugins.gradle.GradleStep) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 2 with GradleStep

use of org.jenkinsci.test.acceptance.plugins.gradle.GradleStep in project acceptance-test-harness by jenkinsci.

the class GradlePluginTest method run_gradle_add_system_properties.

/**
 * Verify the execution of gradle build script with committed gradle system properties.
 */
@Test
public void run_gradle_add_system_properties() {
    GradleInstallation.installGradle(jenkins);
    final FreeStyleJob job = jenkins.jobs.create();
    job.copyResource(resource(GRADLE_SCRIPT), "build.gradle");
    final GradleStep step = job.addBuildStep(GradleStep.class);
    step.setVersion(GradleInstallation.DEFAULT);
    step.setSystemProperties("TEST_PARAM_1=hello\nTEST_PARAM_2=world");
    step.setTasks(JOB_PARAM_AS_SYSTEM_PROPERTIES.getName());
    job.save();
    final Build build = job.startBuild().shouldSucceed();
    assertThat(build.getConsole(), containsString("Gradle Properties: hello world"));
}
Also used : GradleStep(org.jenkinsci.test.acceptance.plugins.gradle.GradleStep) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 3 with GradleStep

use of org.jenkinsci.test.acceptance.plugins.gradle.GradleStep in project acceptance-test-harness by jenkinsci.

the class GradlePluginTest method run_gradle_job_parameters_as_system_properties.

/**
 * Verify the execution of gradle build script with committed parameters as gradle system properties.
 */
@Test
public void run_gradle_job_parameters_as_system_properties() {
    GradleInstallation.installGradle(jenkins);
    final FreeStyleJob job = jenkins.jobs.create();
    job.copyResource(resource(GRADLE_SCRIPT), "build.gradle");
    job.addParameter(StringParameter.class).setName("TEST_PARAM_1").setDefault("hello");
    job.addParameter(StringParameter.class).setName("TEST_PARAM_2").setDefault("world");
    final GradleStep step = job.addBuildStep(GradleStep.class);
    step.setVersion(GradleInstallation.DEFAULT);
    step.setTasks(JOB_PARAM_AS_SYSTEM_PROPERTIES.getName());
    step.setPassAllAsSystemProperties();
    job.save();
    final Build build = job.startBuild().shouldSucceed();
    assertThat(build.getConsole(), containsString("Gradle Properties: hello world"));
}
Also used : GradleStep(org.jenkinsci.test.acceptance.plugins.gradle.GradleStep) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 4 with GradleStep

use of org.jenkinsci.test.acceptance.plugins.gradle.GradleStep in project acceptance-test-harness by jenkinsci.

the class GradlePluginTest method run_gradle_script_build_scan_link.

/**
 * Verify the execution of gradle build and check if build scan links are available
 */
@Test
public void run_gradle_script_build_scan_link() {
    GradleInstallation.installGradle(jenkins);
    final FreeStyleJob job = jenkins.jobs.create();
    job.copyResource(resource(GRADLE_SCRIPT), "build.gradle");
    final GradleStep step = job.addBuildStep(GradleStep.class);
    step.setVersion(GradleInstallation.DEFAULT);
    step.setTasks(HELLO.getName());
    step.setSwitches("--scan");
    job.save();
    final Build build = job.startBuild();
    build.shouldSucceed();
    build.openStatusPage();
    final WebElement buildScanLink = build.find(By.partialLinkText("Gradle Build Scan"));
    assertThat(buildScanLink.getAttribute("href"), containsString("https://gradle.com/"));
}
Also used : GradleStep(org.jenkinsci.test.acceptance.plugins.gradle.GradleStep) WebElement(org.openqa.selenium.WebElement) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 5 with GradleStep

use of org.jenkinsci.test.acceptance.plugins.gradle.GradleStep in project acceptance-test-harness by jenkinsci.

the class GradlePluginTest method run_gradle_tasks_link.

/**
 * Verify the existence of links for executed tasks.
 */
@Test
public void run_gradle_tasks_link() {
    GradleInstallation.installGradle(jenkins);
    final FreeStyleJob job = jenkins.jobs.create();
    job.copyResource(resource(GRADLE_SCRIPT), "build.gradle");
    final GradleStep step = job.addBuildStep(GradleStep.class);
    step.setTasks(FIRST.getName() + " " + SECOND.getName());
    step.setVersion(GradleInstallation.DEFAULT);
    job.save();
    final Build build = job.startBuild().shouldSucceed();
    final WebElement firstTaskLink = build.find(By.partialLinkText(FIRST.getName()));
    final WebElement secondTaskLink = build.find(By.partialLinkText(SECOND.getName()));
    assertThat(firstTaskLink.getAttribute("href"), containsString("#gradle-task-0"));
    assertThat(secondTaskLink.getAttribute("href"), containsString("#gradle-task-1"));
    assertThat(build.getConsole(), containsString(FIRST.getPrintln()));
    assertThat(build.getConsole(), containsString(SECOND.getPrintln()));
}
Also used : GradleStep(org.jenkinsci.test.acceptance.plugins.gradle.GradleStep) WebElement(org.openqa.selenium.WebElement) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)12 GradleStep (org.jenkinsci.test.acceptance.plugins.gradle.GradleStep)12 Test (org.junit.Test)12 WebElement (org.openqa.selenium.WebElement)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.containsString (org.jenkinsci.test.acceptance.Matchers.containsString)1 ArtifactoryContainer (org.jenkinsci.test.acceptance.docker.fixtures.ArtifactoryContainer)1 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)1 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)1 ArtifactoryGradleConfiguratior (org.jenkinsci.test.acceptance.plugins.artifactory.ArtifactoryGradleConfiguratior)1 Build (org.jenkinsci.test.acceptance.po.Build)1 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)1 Ignore (org.junit.Ignore)1 Issue (org.jvnet.hudson.test.Issue)1