Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-27208] Added a test specific for workflow compatibility
- Loading branch information
Manuel Recena
committed
Sep 30, 2015
1 parent
9f8e6b8
commit 95a68a0
Showing
3 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/java/org/jenkinsci/plugins/logparser/LogParserWorkflowTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.jenkinsci.plugins.logparser; | ||
|
||
import hudson.FilePath; | ||
import hudson.plugins.logparser.LogParserAction; | ||
import hudson.plugins.logparser.LogParserPublisher; | ||
import hudson.tasks.Maven; | ||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.junit.*; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* In this test suite we initialize the Job workspaces with a resource (maven-project1.zip) that contains a Maven | ||
* project. | ||
*/ | ||
public class LogParserWorkflowTest { | ||
|
||
@ClassRule | ||
public static JenkinsRule jenkinsRule = new JenkinsRule(); | ||
|
||
private static Maven.MavenInstallation mavenInstallation; | ||
|
||
@BeforeClass | ||
public static void init() throws Exception { | ||
mavenInstallation = jenkinsRule.configureMaven3(); | ||
} | ||
|
||
/** | ||
* Run a workflow job using {@link LogParserPublisher} and check for success. | ||
*/ | ||
@Test | ||
public void logParserPublisherWorkflowStep() throws Exception { | ||
WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "logParserPublisherWorkflowStep"); | ||
FilePath workspace = jenkinsRule.jenkins.getWorkspaceFor(job); | ||
workspace.unzipFrom(getClass().getResourceAsStream("./maven-project1.zip")); | ||
job.setDefinition(new CpsFlowDefinition("" | ||
+ "node {\n" | ||
+ " def mvnHome = tool '" + mavenInstallation.getName() + "'\n" | ||
+ " sh \"${mvnHome}/bin/mvn clean install\"\n" | ||
+ " step([$class: 'LogParserPublisher', projectRulePath: 'logparser-rules.txt', useProjectRule: true])\n" | ||
+ "}\n", true) | ||
); | ||
jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0)); | ||
LogParserAction result = job.getLastBuild().getAction(LogParserAction.class); | ||
assertEquals(0, result.getResult().getTotalErrors()); | ||
assertEquals(2, result.getResult().getTotalWarnings()); | ||
assertEquals(0, result.getResult().getTotalInfos()); | ||
} | ||
|
||
} |
Binary file added
BIN
+4.44 KB
src/test/resources/org/jenkinsci/plugins/logparser/maven-project1.zip
Binary file not shown.