Skip to content
Permalink
Browse files

[JENKINS-20892] Introduced method so that /user/*/rssLatest can check…

… UserIdCause just like /user/*/builds already was.

(cherry picked from commit 76af02e)
  • Loading branch information
jglick authored and olivergondza committed Feb 28, 2014
1 parent 46d4a63 commit 915000b5a0a4c33e02104e47c4b9420192531e07
Showing with 18 additions and 10 deletions.
  1. +18 −10 core/src/main/java/hudson/model/User.java
@@ -429,6 +429,22 @@ public String getDisplayName() {
return getFullName();
}

/** true if {@link AbstractBuild#hasParticipant} or {@link hudson.model.Cause.UserIdCause} */
private boolean relatedTo(AbstractBuild<?,?> b) {
if (b.hasParticipant(this)) {
return true;
}
for (Cause cause : b.getCauses()) {
if (cause instanceof Cause.UserIdCause) {
String userId = ((Cause.UserIdCause) cause).getUserId();
if (userId != null && userId.equals(getId())) {
return true;
}
}
}
return false;
}

/**
* Gets the list of {@link Build}s that include changes by this user,
* by the timestamp order.
@@ -440,16 +456,8 @@ public RunList getBuilds() {
List<AbstractBuild> r = new ArrayList<AbstractBuild>();
for (AbstractProject<?,?> p : Jenkins.getInstance().getAllItems(AbstractProject.class))
for (AbstractBuild<?,?> b : p.getBuilds().newBuilds()){
if(b.hasParticipant(this))
if (relatedTo(b)) {
r.add(b);
else {
//append builds that were run by this user
Cause.UserIdCause cause = b.getCause(Cause.UserIdCause.class);
if (cause != null) {
String userId = cause.getUserId();
if (userId != null && this.getId() != null && userId.equals(this.getId()))
r.add(b);
}
}
}
return RunList.fromRuns(r);
@@ -581,7 +589,7 @@ public void doRssLatest(StaplerRequest req, StaplerResponse rsp) throws IOExcept
final List<Run> lastBuilds = new ArrayList<Run>();
for (AbstractProject<?,?> p : Jenkins.getInstance().getAllItems(AbstractProject.class)) {
for (AbstractBuild<?,?> b = p.getLastBuild(); b != null; b = b.getPreviousBuild()) {
if (b.hasParticipant(this)) { // TODO or check UserIdCause
if (relatedTo(b)) {
lastBuilds.add(b);
break;
}

0 comments on commit 915000b

Please sign in to comment.
You can’t perform that action at this time.