mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 20:12:14 +00:00
[FIXED HUDSON-1938] Moved Maven project's block when upstream is building functionality up to AbstractProject. Now available as advanced option for all project types
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21323 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
3b67a0847d
commit
feb3b5b508
10 files changed
+112
-66
No files matched your search
@@ -147,6 +147,12 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
*/
|
||||
protected volatile boolean disabled;
|
||||
|
||||
/**
|
||||
* True to keep builds of this project in queue when upstream projects are
|
||||
* building. False by default to keep from breaking existing behavior.
|
||||
*/
|
||||
protected volatile boolean blockBuildWhenUpstreamBuilding = false;
|
||||
|
||||
/**
|
||||
* Identifies {@link JDK} to be used.
|
||||
* Null if no explicit configuration is required.
|
||||
@@ -411,6 +417,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean blockBuildWhenUpstreamBuilding() {
|
||||
return blockBuildWhenUpstreamBuilding;
|
||||
}
|
||||
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
@@ -818,20 +828,58 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
|
||||
*
|
||||
* <p>
|
||||
* A project must be blocked if its own previous build is in progress,
|
||||
* but derived classes can also check other conditions.
|
||||
* or if the blockBuildWhenUpstreamBuilding option is true and an upstream
|
||||
* project is building, but derived classes can also check other conditions.
|
||||
*/
|
||||
public boolean isBuildBlocked() {
|
||||
return isBuilding() && !isConcurrentBuild();
|
||||
boolean blocked = isBuilding() && !isConcurrentBuild();
|
||||
if (!blocked && blockBuildWhenUpstreamBuilding) {
|
||||
AbstractProject bup = getBuildingUpstream();
|
||||
if(bup!=null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return blocked;
|
||||
|
||||
}
|
||||
|
||||
public String getWhyBlocked() {
|
||||
AbstractBuild<?, ?> build = getLastBuild();
|
||||
Executor e = build.getExecutor();
|
||||
String eta="";
|
||||
if(e!=null)
|
||||
eta = Messages.AbstractProject_ETA(e.getEstimatedRemainingTime());
|
||||
int lbn = build.getNumber();
|
||||
return Messages.AbstractProject_BuildInProgress(lbn,eta);
|
||||
if (isBuilding() && !isConcurrentBuild()) {
|
||||
AbstractBuild<?, ?> build = getLastBuild();
|
||||
Executor e = build.getExecutor();
|
||||
String eta="";
|
||||
if(e!=null)
|
||||
eta = Messages.AbstractProject_ETA(e.getEstimatedRemainingTime());
|
||||
int lbn = build.getNumber();
|
||||
return Messages.AbstractProject_BuildInProgress(lbn,eta);
|
||||
}
|
||||
else {
|
||||
AbstractProject bup = getBuildingUpstream();
|
||||
String projectName = "";
|
||||
if(bup!=null) {
|
||||
projectName = bup.getName();
|
||||
}
|
||||
return Messages.AbstractProject_UpstreamBuildInProgress(projectName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the project if any of the upstream project (or itself) is either
|
||||
* building or is in the queue.
|
||||
* <p>
|
||||
* This means eventually there will be an automatic triggering of
|
||||
* the given project (provided that all builds went smoothly.)
|
||||
*/
|
||||
protected AbstractProject getBuildingUpstream() {
|
||||
DependencyGraph graph = Hudson.getInstance().getDependencyGraph();
|
||||
Set<AbstractProject> tups = graph.getTransitiveUpstream(this);
|
||||
tups.add(this);
|
||||
for (AbstractProject tup : tups) {
|
||||
if(tup!=this && (tup.isBuilding() || tup.isInQueue()))
|
||||
return tup;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final long getEstimatedDuration() {
|
||||
|
||||
Reference in new issue
Block a user