use of org.jenkinsci.test.acceptance.plugins.textfinder.TextFinderPublisher in project acceptance-test-harness by jenkinsci.
the class NodeLabelParameterPluginTest method trigger_if_succeeds_with_failed_post_build_step.
/**
* This test is intended to verify that the second build is not started when the
* build already failed on the first slave in combination with the
* "run next build only if build succeeds" setting of the node parameter.
* <p/>
* As a build can fail in different stages this test simulates a FAILED result
* during the post build step. Therefore the text-finder plugin is used to
* fail the build based on a simple pattern matching with a text file copied to
* the slave's workspace.
* <p/>
* Note that in this case the main build action is still completed with status SUCCESS.
*/
@Test
@WithPlugins("text-finder")
@Issue("JENKINS-23129")
@Ignore("Until JENKINS-23129 is fixed")
public void trigger_if_succeeds_with_failed_post_build_step() throws Exception {
FreeStyleJob j = jenkins.jobs.create();
ArrayList<Node> slaves = new ArrayList<>();
slaves.add(slave.install(jenkins).get());
slaves.add(slave.install(jenkins).get());
j.configure();
// set up the node parameter
NodeParameter p = j.addParameter(NodeParameter.class);
p.setName("slavename");
p.runIfSuccess.check();
// copy the file to mark the status
j.copyResource(resource("/textfinder_plugin/textfinder-result_failed.log"));
// set up the post build action
TextFinderPublisher tf = j.addPublisher(TextFinderPublisher.class);
tf.filePath.sendKeys("textfinder-result_failed.log");
tf.regEx.sendKeys("^RESULT=SUCCESS$");
tf.succeedIfFound.click();
j.save();
// select both slaves for this build
j.startBuild(singletonMap("slavename", slaves.get(0).getName() + "," + slaves.get(1).getName())).shouldFail();
// verify failed result prevents the job to be built on further nodes.
// As the nodes get random names and the selected nodes are utilized in alphabetical order
// of their names, the first build will not necessarily be done on s1. Thus, it can only
// be verified that the job has been built on one of the slaves.
j.startBuild(singletonMap("slavename", slaves.get(0).getName() + "," + slaves.get(1).getName())).shouldFail();
assertThat(j.getNextBuildNumber(), is(2));
}
Aggregations