use of org.jenkinsci.test.acceptance.po.Artifact in project acceptance-test-harness by jenkinsci.
the class FreestyleJobTest method archiveArtifacts.
@Test
@Category(SmokeTest.class)
public void archiveArtifacts() {
FreeStyleJob j = jenkins.jobs.create(FreeStyleJob.class);
j.configure();
j.addShellStep("echo 'yes' > include; echo 'no' > exclude;");
ArtifactArchiver archiver = j.addPublisher(ArtifactArchiver.class);
archiver.includes("**/*include*");
archiver.excludes("exclude");
j.save();
Build build = j.scheduleBuild().waitUntilFinished();
assertThat(build.getArtifact("exclude"), pageObjectDoesNotExist());
Artifact include = build.getArtifact("include");
assertThat(include, pageObjectExists());
assertThat(include.getTextContent(), equalTo("yes"));
}
use of org.jenkinsci.test.acceptance.po.Artifact in project acceptance-test-harness by jenkinsci.
the class CompressArtifactsPluginTest method compareArtifacts.
private void compareArtifacts(Build lhs, Build rhs) {
final List<Artifact> lhsArtifacts = lhs.getArtifacts();
for (Artifact ra : lhsArtifacts) {
String rap = ra.getRelativePath();
assertEquals(rap, rhs.getArtifact(rap).getRelativePath());
}
assertEquals("Artifacts differs", lhsArtifacts.size(), rhs.getArtifacts().size());
assertThat("No artifacts", lhsArtifacts.size(), greaterThan(0));
}
use of org.jenkinsci.test.acceptance.po.Artifact in project acceptance-test-harness by jenkinsci.
the class WorkflowPluginTest method linearFlow.
@WithPlugins({ "workflow-job", "workflow-cps@2.10", "workflow-basic-steps@2.1", "workflow-durable-task-step", "pipeline-input-step", "junit@1.18", "git@2.3" })
@Test
public void linearFlow() throws Exception {
assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
MavenInstallation.installMaven(jenkins, "M3", "3.5.0");
final DumbSlave slave = (DumbSlave) slaveController.install(jenkins).get();
slave.configure(() -> slave.labels.set("remote"));
WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
job.script.set("node('remote') {\n" + " git 'https://github.com/jglick/simple-maven-project-with-tests.git'\n" + " def v = version()\n" + " if (v) {\n" + " echo(/Building version $v/)\n" + " }\n" + " def mvnHome = tool 'M3'\n" + " withEnv([\"PATH+MAVEN=$mvnHome/bin\", \"M2_HOME=$mvnHome\"]) {\n" + " sh 'mvn -B -Dmaven.test.failure.ignore verify'\n" + " }\n" + " input 'Ready to go?'\n" + " archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true\n" + " junit '**/target/surefire-reports/TEST-*.xml'\n" + "}\n" + "def version() {\n" + " def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'\n" + " matcher ? matcher[0][1] : null\n" + "}");
job.sandbox.check();
job.save();
final Build build = job.startBuild();
waitFor().until(new Wait.Predicate<Boolean>() {
@Override
public Boolean apply() throws Exception {
return build.getConsole().contains("Ready to go?");
}
@Override
public String diagnose(Throwable lastException, String message) {
return "Console output:\n" + build.getConsole() + "\n";
}
});
assertThat(build.getConsole(), containsString("Building version 1.0-SNAPSHOT"));
jenkins.restart();
// Default 120s timeout of Build.waitUntilFinished sometimes expires waiting for RetentionStrategy.Always to tick (after initial failure of CommandLauncher.launch: EOFException: unexpected stream termination):
// TODO rather wait for build output: "Ready to run"
slave.waitUntilOnline();
visit(build.getConsoleUrl());
clickLink("Proceed");
try {
build.shouldSucceed();
} catch (AssertionError x) {
// Tests in this project are currently designed to fail at random, so either status is OK.
// TODO if resultIs were public and there were a disjunction combinator for Matcher we could use it here.
build.shouldBeUnstable();
}
new Artifact(build, "target/simple-maven-project-with-tests-1.0-SNAPSHOT.jar").assertThatExists(true);
build.open();
clickLink("Test Result");
assertThat(driver, hasContent("All Tests"));
}
Aggregations