diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java
index a0ce3a6536..aadecaa51c 100644
--- a/core/src/main/java/hudson/Functions.java
+++ b/core/src/main/java/hudson/Functions.java
@@ -270,4 +270,19 @@ public class Functions {
}
return false;
}
+
+ /**
+ * Finds the given object in the ancestor list and returns its URL.
+ * This is used to determine the "current" URL assigned to the given object,
+ * so that one can compute relative URLs from it.
+ */
+ public static String getNearestAncestorUrl(StaplerRequest req,Object it) {
+ List list = req.getAncestors();
+ for( int i=list.size()-1; i>=0; i-- ) {
+ Ancestor anc = (Ancestor) list.get(i);
+ if(anc.getObject()==it)
+ return anc.getUrl();
+ }
+ return null;
+ }
}
diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java
index a2655e9000..1e72ad29a5 100644
--- a/core/src/main/java/hudson/model/View.java
+++ b/core/src/main/java/hudson/model/View.java
@@ -56,6 +56,10 @@ public class View extends JobCollection {
return Arrays.asList(jobs);
}
+ public Job getJob(String name) {
+ return owner.getJob(name);
+ }
+
public boolean containsJob(Job job) {
return jobNames.contains(job.getName());
}
diff --git a/core/src/main/resources/hudson/model/AbstractProject/sidepanel.jelly b/core/src/main/resources/hudson/model/AbstractProject/sidepanel.jelly
index 82a24c1f4e..ca8c4af009 100644
--- a/core/src/main/resources/hudson/model/AbstractProject/sidepanel.jelly
+++ b/core/src/main/resources/hudson/model/AbstractProject/sidepanel.jelly
@@ -7,16 +7,17 @@