mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
downstream/upstream computation can be moved up to AbstractBuild.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2016 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
4f1955253a
commit
26574c6d52
4 files changed
+31
-63
No files matched your search
@@ -58,18 +58,6 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
|
||||
run(new RunnerImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RangeSet getDownstreamRelationship(AbstractProject that) {
|
||||
// TODO
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpstreamRelationship(AbstractProject that) {
|
||||
// TODO
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs Maven and builds the project.
|
||||
*
|
||||
|
||||
@@ -2,10 +2,8 @@ package hudson.maven;
|
||||
|
||||
import hudson.FilePath.FileCallable;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.Build;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.model.Fingerprint.RangeSet;
|
||||
import hudson.model.Hudson;
|
||||
import hudson.model.Result;
|
||||
import hudson.remoting.VirtualChannel;
|
||||
@@ -52,16 +50,6 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
|
||||
run(new RunnerImpl());
|
||||
}
|
||||
|
||||
public RangeSet getDownstreamRelationship(AbstractProject that) {
|
||||
// TODO
|
||||
return new RangeSet();
|
||||
}
|
||||
|
||||
public int getUpstreamRelationship(AbstractProject that) {
|
||||
// TODO
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The sole job of the {@link MavenModuleSet} build is to update SCM
|
||||
* and triggers module builds.
|
||||
|
||||
@@ -8,6 +8,7 @@ import hudson.maven.MavenBuild;
|
||||
import static hudson.model.Hudson.isWindows;
|
||||
import hudson.model.listeners.SCMListener;
|
||||
import hudson.model.Fingerprint.RangeSet;
|
||||
import hudson.model.Fingerprint.BuildPtr;
|
||||
import hudson.scm.CVSChangeLogParser;
|
||||
import hudson.scm.ChangeLogParser;
|
||||
import hudson.scm.ChangeLogSet;
|
||||
@@ -246,7 +247,21 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
* range of build numbers that represent which downstream builds are using this build.
|
||||
* The range will be empty if no build of that project matches this.
|
||||
*/
|
||||
public abstract RangeSet getDownstreamRelationship(AbstractProject that);
|
||||
public RangeSet getDownstreamRelationship(AbstractProject that) {
|
||||
RangeSet rs = new RangeSet();
|
||||
|
||||
FingerprintAction f = getAction(FingerprintAction.class);
|
||||
if(f==null) return rs;
|
||||
|
||||
// look for fingerprints that point to this build as the source, and merge them all
|
||||
for (Fingerprint e : f.getFingerprints().values()) {
|
||||
BuildPtr o = e.getOriginal();
|
||||
if(o!=null && o.is(this))
|
||||
rs.add(e.getRangeSet(that));
|
||||
}
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dependency relationship from this build (as the sink)
|
||||
@@ -256,7 +271,21 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
* Build number of the upstream build that feed into this build,
|
||||
* or -1 if no record is available.
|
||||
*/
|
||||
public abstract int getUpstreamRelationship(AbstractProject that);
|
||||
public int getUpstreamRelationship(AbstractProject that) {
|
||||
FingerprintAction f = getAction(FingerprintAction.class);
|
||||
if(f==null) return -1;
|
||||
|
||||
int n = -1;
|
||||
|
||||
// look for fingerprints that point to the given project as the source, and merge them all
|
||||
for (Fingerprint e : f.getFingerprints().values()) {
|
||||
BuildPtr o = e.getOriginal();
|
||||
if(o!=null && o.is(that))
|
||||
n = Math.max(n,o.getNumber());
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the downstream builds of this build, which are the builds of the
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package hudson.model;
|
||||
|
||||
import hudson.model.Fingerprint.BuildPtr;
|
||||
import hudson.model.Fingerprint.RangeSet;
|
||||
import hudson.tasks.BuildStep;
|
||||
import hudson.tasks.BuildWrapper;
|
||||
import hudson.tasks.BuildWrapper.Environment;
|
||||
import hudson.tasks.Builder;
|
||||
import hudson.tasks.Fingerprinter.FingerprintAction;
|
||||
import hudson.tasks.Publisher;
|
||||
import hudson.tasks.test.AbstractTestResultAction;
|
||||
import hudson.triggers.SCMTrigger;
|
||||
@@ -50,40 +47,6 @@ public final class Build extends AbstractBuild<Project,Build> {
|
||||
return getAction(AbstractTestResultAction.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RangeSet getDownstreamRelationship(AbstractProject that) {
|
||||
RangeSet rs = new RangeSet();
|
||||
|
||||
FingerprintAction f = getAction(FingerprintAction.class);
|
||||
if(f==null) return rs;
|
||||
|
||||
// look for fingerprints that point to this build as the source, and merge them all
|
||||
for (Fingerprint e : f.getFingerprints().values()) {
|
||||
BuildPtr o = e.getOriginal();
|
||||
if(o!=null && o.is(this))
|
||||
rs.add(e.getRangeSet(that));
|
||||
}
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpstreamRelationship(AbstractProject that) {
|
||||
FingerprintAction f = getAction(FingerprintAction.class);
|
||||
if(f==null) return -1;
|
||||
|
||||
int n = -1;
|
||||
|
||||
// look for fingerprints that point to the given project as the source, and merge them all
|
||||
for (Fingerprint e : f.getFingerprints().values()) {
|
||||
BuildPtr o = e.getOriginal();
|
||||
if(o!=null && o.is(that))
|
||||
n = Math.max(n,o.getNumber());
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* During the build this field remembers {@link Environment}s created by
|
||||
* {@link BuildWrapper}. This design is bit ugly but forced due to compatibility.
|
||||
|
||||
Reference in new issue
Block a user