Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinston Prakash2014-09-19 17:49:35 -0400
committerWinston Prakash2014-09-19 17:49:35 -0400
commitb92a0016b72b6fcef36d22769ad101248e986d28 (patch)
tree127e2a6ff3c7aaf4598c46baa1b3cd4e8a05c8c4
parent4fd536c39903050ae506c578765ac5cb8fad209f (diff)
downloadorg.eclipse.hudson.core-b92a0016b72b6fcef36d22769ad101248e986d28.tar.gz
org.eclipse.hudson.core-b92a0016b72b6fcef36d22769ad101248e986d28.tar.xz
org.eclipse.hudson.core-b92a0016b72b6fcef36d22769ad101248e986d28.zip
Fix: 443742 - Promotion plugin not running promoted job
-rw-r--r--hudson-core/src/main/java/hudson/model/JobProperty.java9
-rw-r--r--hudson-core/src/main/java/hudson/model/queue/MappingWorksheet.java47
2 files changed, 52 insertions, 4 deletions
diff --git a/hudson-core/src/main/java/hudson/model/JobProperty.java b/hudson-core/src/main/java/hudson/model/JobProperty.java
index 078b53ad..cf112dee 100644
--- a/hudson-core/src/main/java/hudson/model/JobProperty.java
+++ b/hudson-core/src/main/java/hudson/model/JobProperty.java
@@ -78,6 +78,15 @@ public abstract class JobProperty<J extends Job<?, ?>> implements Describable<Jo
protected void setOwner(J owner) {
this.owner = owner;
}
+
+ /**
+ * Get the owner of this property
+ * @since 3.2.1
+ * @return owner
+ */
+ public J getOwner() {
+ return owner;
+ }
/**
* {@inheritDoc}
diff --git a/hudson-core/src/main/java/hudson/model/queue/MappingWorksheet.java b/hudson-core/src/main/java/hudson/model/queue/MappingWorksheet.java
index 5166a4e4..b2ca801a 100644
--- a/hudson-core/src/main/java/hudson/model/queue/MappingWorksheet.java
+++ b/hudson-core/src/main/java/hudson/model/queue/MappingWorksheet.java
@@ -19,9 +19,12 @@ package hudson.model.queue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import hudson.matrix.MatrixConfiguration;
+import hudson.model.AbstractProject;
import hudson.model.Computer;
import hudson.model.Executor;
import hudson.model.Hudson;
+import hudson.model.ItemGroup;
+import hudson.model.JobProperty;
import hudson.model.Label;
import hudson.model.LoadBalancer;
import hudson.model.Node;
@@ -42,6 +45,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import org.eclipse.hudson.security.team.Team;
import org.eclipse.hudson.security.team.TeamManager;
/**
@@ -350,13 +354,48 @@ public class MappingWorksheet {
TeamManager teamManager = Hudson.getInstance().getTeamManager();
if (teamManager.isTeamManagementEnabled()) {
String name = c.getName();
- if (c instanceof Hudson.MasterComputer){
+ if (c instanceof Hudson.MasterComputer) {
name = "Master";
}
String jobName = item.task.getName();
- if (item.task instanceof MatrixConfiguration){
- MatrixConfiguration matrixConfiguration = (MatrixConfiguration) item.task;
- jobName = matrixConfiguration.getParent().getName();
+ //All jobs must be part of a team, if not this task item may be a sub-job.
+ //Try to find the parent job that belongs to the team
+ Team jobTeam = teamManager.findJobOwnerTeam(jobName);
+ if (jobTeam == null) {
+ AbstractProject jobTask = null;
+ if (item.task instanceof AbstractProject) {
+ jobTask = (AbstractProject) item.task;
+ }
+ if (jobTask != null) {
+ do {
+ // Check if the parent of this sub-job is a team job
+ if (jobTask.getParent() instanceof AbstractProject) {
+ jobTask = (AbstractProject) jobTask.getParent();
+ jobName = jobTask.getName();
+ jobTeam = teamManager.findJobOwnerTeam(jobName);
+ } else if (jobTask.getParent() instanceof ItemGroup) {
+ ItemGroup itemGroup = (ItemGroup) jobTask.getParent();
+ // This item group may be added as Job property to parent
+ if (itemGroup instanceof JobProperty) {
+ JobProperty property = (JobProperty) itemGroup;
+ if (property.getOwner() instanceof AbstractProject) {
+ jobTask = (AbstractProject) property.getOwner();
+ jobName = jobTask.getName();
+ jobTeam = teamManager.findJobOwnerTeam(jobName);
+ }
+ }
+ } else {
+ break;
+ }
+ } while (jobTeam == null);
+ }
+ }
+ // If job team is still null do a last ditch test
+ if (jobTeam == null) {
+ if (item.task instanceof MatrixConfiguration) {
+ MatrixConfiguration matrixConfiguration = (MatrixConfiguration) item.task;
+ jobName = matrixConfiguration.getParent().getName();
+ }
}
canBuildInNode = teamManager.canNodeExecuteJob(name, jobName);
}

Back to the top