Search in sources :

Example 31 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class ArtifactoryPluginTest method gradle_integration.

@Test
@WithPlugins("gradle")
@Ignore
@Issue("JENKINS-39323")
public void gradle_integration() {
    final ArtifactoryContainer artifactory = artifactoryContainer.get();
    waitForArtifactory(artifactory);
    configureArtifactory(artifactory);
    GradleInstallation.installGradle(jenkins, "gradle 2.0", "2.0");
    FreeStyleJob job = jenkins.jobs.create();
    job.copyDir(resource("/artifactory_plugin/quickstart"));
    ArtifactoryGradleConfiguratior gradleConfig = new ArtifactoryGradleConfiguratior(job);
    gradleConfig.refresh();
    GradleStep gradle = job.addBuildStep(GradleStep.class);
    gradle.setVersion("gradle 2.0");
    // gradle.tasks.set("build --stacktrace --debug");
    gradle.setTasks("build");
    job.save();
    Build build = job.startBuild().shouldSucceed();
    String log = build.getConsole();
    assertThat(log, containsString("build artifactoryPublish"));
    assertThat(log, containsString("[buildinfo]"));
    assertThat(log, containsString("Deploying artifact"));
    assertThat(log, containsRegexp("Deploying build (info|descriptor) to: " + artifactory.getURL() + "/api/build"));
}
Also used : ArtifactoryContainer(org.jenkinsci.test.acceptance.docker.fixtures.ArtifactoryContainer) Build(org.jenkinsci.test.acceptance.po.Build) GradleStep(org.jenkinsci.test.acceptance.plugins.gradle.GradleStep) ArtifactoryGradleConfiguratior(org.jenkinsci.test.acceptance.plugins.artifactory.ArtifactoryGradleConfiguratior) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Matchers.containsString(org.hamcrest.Matchers.containsString) Ignore(org.junit.Ignore) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 32 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class DeclarativePipelineTest method basicDeclarativeTests.

@WithPlugins("pipeline-model-definition")
@Test
public void basicDeclarativeTests() throws Exception {
    WorkflowJob helloWorldJob = jenkins.jobs.create(WorkflowJob.class);
    helloWorldJob.script.set("pipeline {\n" + "  agent none\n" + "  stages {\n" + "    stage('foo') {\n" + "      steps {\n" + "        echo 'Hello world'\n" + "      }\n" + "    }\n" + "  }\n" + "}\n");
    helloWorldJob.sandbox.check();
    helloWorldJob.save();
    Build helloWorldBuild = helloWorldJob.startBuild().shouldSucceed();
    assertThat(helloWorldBuild.getConsole(), containsRegexp("Hello world", Pattern.MULTILINE));
    MavenInstallation.installMaven(jenkins, "M3", "3.1.0");
    final DumbSlave slave = (DumbSlave) slaveController.install(jenkins).get();
    slave.configure(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            slave.labels.set("remote");
            return null;
        }
    });
    WorkflowJob toolsEnvAgentJob = jenkins.jobs.create(WorkflowJob.class);
    toolsEnvAgentJob.script.set("pipeline {\n" + "  agent { label 'remote' }\n" + "  tools {\n" + "    maven 'M3'\n" + "  }\n" + "  environment {\n" + "    FOO = 'BAR'\n" + "  }\n" + "  stages {\n" + "    stage('first') {\n" + "      steps {\n" + "        sh 'mvn --version'\n" + "      }\n" + "    }\n" + "    stage('second') {\n" + "      steps {\n" + "        echo \"FOO is ${env.FOO}\"\n" + "      }\n" + "    }\n" + "  }\n" + "}\n");
    toolsEnvAgentJob.sandbox.check();
    toolsEnvAgentJob.save();
    Build toolsEnvAgentBuild = toolsEnvAgentJob.startBuild().shouldSucceed();
    String toolsEnvAgentConsole = toolsEnvAgentBuild.getConsole();
    assertThat(toolsEnvAgentConsole, containsRegexp("\\(first\\)", Pattern.MULTILINE));
    assertThat(toolsEnvAgentConsole, containsRegexp("Apache Maven 3\\.1\\.0", Pattern.MULTILINE));
    assertThat(toolsEnvAgentConsole, containsRegexp("\\(second\\)", Pattern.MULTILINE));
    assertThat(toolsEnvAgentConsole, containsRegexp("FOO is BAR", Pattern.MULTILINE));
    WorkflowJob missingAgentJob = jenkins.jobs.create(WorkflowJob.class);
    missingAgentJob.script.set("pipeline {\n" + "  stages {\n" + "    stage('foo') {\n" + "      steps {\n" + "        echo 'Hello world'\n" + "      }\n" + "    }\n" + "  }\n" + "}\n");
    missingAgentJob.sandbox.check();
    missingAgentJob.save();
    Build missingAgentBuild = missingAgentJob.startBuild().shouldFail();
    String missingAgentConsole = missingAgentBuild.getConsole();
    assertThat(missingAgentConsole, containsRegexp("Missing required section ['\"]agent['\"]"));
    assertThat(missingAgentConsole, not(containsRegexp("Hello world")));
    WorkflowJob missingToolVersionJob = jenkins.jobs.create(WorkflowJob.class);
    missingToolVersionJob.script.set("pipeline {\n" + "  agent { label 'remote' }\n" + "  tools {\n" + "    maven 'some-other-version'\n" + "  }\n" + "  environment {\n" + "    FOO = 'BAR'\n" + "  }\n" + "  stages {\n" + "    stage('first') {\n" + "      steps {\n" + "        sh 'mvn --version'\n" + "      }\n" + "    }\n" + "    stage('second') {\n" + "      steps {\n" + "        echo \"FOO is ${env.FOO}\"\n" + "      }\n" + "    }\n" + "  }\n" + "}\n");
    missingToolVersionJob.sandbox.check();
    missingToolVersionJob.save();
    Build missingToolVersionBuild = missingToolVersionJob.startBuild().shouldFail();
    String missingToolVersionConsole = missingToolVersionBuild.getConsole();
    assertThat(missingToolVersionConsole, containsRegexp("Tool type ['\"]maven['\"] does not have an install of ['\"]some-other-version['\"] configured"));
    assertThat(missingToolVersionConsole, not(containsRegexp("FOO is BAR")));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 33 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class CompressArtifactsPluginTest method archiveMavenProject.

@Test
@Issue("JENKINS-27558")
@WithPlugins("maven-plugin")
public void archiveMavenProject() {
    MavenInstallation.installSomeMaven(jenkins);
    MavenModuleSet mp = jenkins.jobs.create(MavenModuleSet.class);
    mp.configure();
    mp.copyDir(resource("/maven_plugin/multimodule/"));
    mp.goals.set("clean package -B -DskipTests=true");
    mp.addPublisher(ArtifactArchiver.class).includes("module_a/**/*");
    mp.save();
    MavenBuild raw = mp.startBuild().shouldSucceed().as(MavenBuild.class);
    CompressingArtifactManager.setup(jenkins);
    MavenBuild compressed = mp.startBuild().shouldSucceed().as(MavenBuild.class);
    compareArtifacts(raw, compressed);
    compareArtifacts(raw.module("gid$root"), compressed.module("gid$root"));
    compareArtifacts(raw.module("gid$module_a"), compressed.module("gid$module_a"));
    compareArtifacts(raw.module("gid$module_b"), compressed.module("gid$module_b"));
}
Also used : MavenBuild(org.jenkinsci.test.acceptance.plugins.maven.MavenBuild) ArtifactArchiver(org.jenkinsci.test.acceptance.po.ArtifactArchiver) MavenModuleSet(org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 34 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class ParameterizedTriggerTest method triggerWithNonStandardArchiver.

@Test
@WithPlugins({ "compress-artifacts", "matrix-project" /*JENKINS-33910*/
})
@Issue("JENKINS-28980")
public void triggerWithNonStandardArchiver() {
    CompressingArtifactManager.setup(jenkins);
    FreeStyleJob target = jenkins.jobs.create();
    target.configure();
    target.addParameter(StringParameter.class).setName("PARAM");
    target.addShellStep("test 'value' = $PARAM");
    target.save();
    FreeStyleJob trigger = jenkins.jobs.create();
    trigger.configure();
    trigger.addShellStep("echo 'PARAM=value' > my.properties");
    ArtifactArchiver archiver = trigger.addPublisher(ArtifactArchiver.class);
    archiver.includes("my.properties");
    ParameterizedTrigger step = trigger.addPublisher(ParameterizedTrigger.class);
    TriggerConfig config = step.getTriggerConfig(0);
    config.projects.set(target.name);
    FileBuildParameters params = config.addParameter(FileBuildParameters.class);
    params.file.set("my.properties");
    params.failIfMissing.check();
    trigger.save();
    trigger.startBuild().shouldSucceed();
    Build downstream = target.build(1);
    downstream.shouldSucceed();
}
Also used : StringParameter(org.jenkinsci.test.acceptance.po.StringParameter) ParameterizedTrigger(org.jenkinsci.test.acceptance.plugins.parameterized_trigger.ParameterizedTrigger) ArtifactArchiver(org.jenkinsci.test.acceptance.po.ArtifactArchiver) Build(org.jenkinsci.test.acceptance.po.Build) TriggerConfig(org.jenkinsci.test.acceptance.plugins.parameterized_trigger.TriggerConfig) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) FileBuildParameters(org.jenkinsci.test.acceptance.plugins.parameterized_trigger.FileBuildParameters) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 35 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class MailWatcherPluginTest method notify_master_on_jenkins_restart.

@Test
@Issue("JENKINS-20538")
@Since("1.571")
@WithPlugins("mail-watcher-plugin@1.7")
@Ignore("Flaky test, passes sometimes on CI")
public void notify_master_on_jenkins_restart() throws Exception {
    assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
    jenkins.configure();
    {
        OnlineStatusNotification notification = new OnlineStatusNotification(jenkins);
        notification.onOnline("on@online.com");
        notification.onOffline("on@offline.com");
    }
    jenkins.save();
    jenkins.restart();
    mailhog.assertMail(regex("Computer master marked offline"), "on@offline.com", regex("Jenkins is restarting"));
    mailhog.assertMail(regex("Computer master marked online"), "on@online.com");
}
Also used : OnlineStatusNotification(org.jenkinsci.test.acceptance.plugins.mail_watcher.OnlineStatusNotification) Ignore(org.junit.Ignore) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest) Since(org.jenkinsci.test.acceptance.junit.Since) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Aggregations

WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)89 Test (org.junit.Test)89 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)71 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)53 Build (org.jenkinsci.test.acceptance.po.Build)39 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)31 Issue (org.jvnet.hudson.test.Issue)25 Job (org.jenkinsci.test.acceptance.po.Job)19 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)15 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)15 ListView (org.jenkinsci.test.acceptance.po.ListView)13 View (org.jenkinsci.test.acceptance.po.View)13 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)12 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)11 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)10 Matchers.containsString (org.hamcrest.Matchers.containsString)9 GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)9 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)8 Ignore (org.junit.Ignore)8 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)5