Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #34 from jonsten/JENKINS-40255
[JENKINS-40255] Changed getSCMs(), now it checks for successful builds first.
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowJobTest.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,42 @@ | ||
package org.jenkinsci.plugins.workflow.job; | ||
|
||
|
||
import hudson.model.Result; | ||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class WorkflowJobTest { | ||
@Rule public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Issue("JENKINS-40255") | ||
@Test public void getSCM() throws Exception { | ||
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p"); | ||
p.setDefinition(new CpsFlowDefinition( | ||
"node {\n" + | ||
" checkout(new hudson.scm.NullSCM())\n" + | ||
"}")); | ||
assertTrue("No runs has been performed and there should be no SCMs", p.getSCMs().isEmpty()); | ||
|
||
j.buildAndAssertSuccess(p); | ||
|
||
assertEquals("Expecting one SCM", 1, p.getSCMs().size()); | ||
|
||
p.setDefinition(new CpsFlowDefinition("error 'Fail!'")); | ||
|
||
j.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0)); | ||
|
||
assertEquals("Expecting one SCM even though last run failed",1, p.getSCMs().size()); | ||
|
||
p.setDefinition(new CpsFlowDefinition("echo 'Pass!'")); | ||
|
||
j.buildAndAssertSuccess(p); | ||
|
||
assertEquals("Expecting zero SCMs",0, p.getSCMs().size()); | ||
} | ||
} |