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"));
}
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")));
}
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"));
}
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();
}
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");
}
Aggregations