Skip to content

Commit

Permalink
Merge branch 'JENKINS-20662' of github.com:daniel-beck/jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Apr 23, 2014
2 parents 54c5df2 + b59c490 commit b227088
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java
Expand Up @@ -183,6 +183,7 @@ public final synchronized RunT newBuild() throws IOException {
try {
RunT lastBuild = getBuildClass().getConstructor(asJob().getClass()).newInstance(asJob());
builds.put(lastBuild);
lastBuild.getPreviousBuild(); // JENKINS-20662: create connection to previous build
return lastBuild;
} catch (InstantiationException e) {
throw new Error(e);
Expand Down
26 changes: 26 additions & 0 deletions test/src/test/groovy/jenkins/model/lazy/LazyBuildMixIn_Test.groovy
@@ -0,0 +1,26 @@
package jenkins.model.lazy

import hudson.model.Run
import hudson.model.TaskListener
import hudson.model.listeners.RunListener
import org.junit.Rule
import org.junit.Test
import org.jvnet.hudson.test.Bug
import org.jvnet.hudson.test.SleepBuilder
import org.jvnet.hudson.test.JenkinsRule

class LazyBuildMixIn_Test {
@Rule
public JenkinsRule r = new JenkinsRule();

@Test
@Bug(20662)
public void testNewRunningBuildRelationFromPrevious() {
def p = r.createFreeStyleProject();
p.buildersList.replaceBy([new SleepBuilder(1000)])
def b1 = p.scheduleBuild2(0).get();
assert null == b1.getNextBuild();
def b2 = p.scheduleBuild2(0).waitForStart();
assert b2 == b1.getNextBuild();
}
}

0 comments on commit b227088

Please sign in to comment.