提交 9c197b24 编写于 作者: V Vojtech Juranek

Merge pull421

Conflicts:
	changelog.html
......@@ -67,7 +67,9 @@ Upcoming changes</a>
<li class=rfe>
Added the View.READ permission to control visibility of views, and updated the default implementation to hide empty views.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-3681">issue 3681</a>)
<li class=rfe>
Added new extension point for transient build actions.
(<a href="https://github.com/jenkinsci/jenkins/pull/421">pull 421</a>)
</ul>
</div><!--=TRUNK-END=-->
......
......@@ -87,6 +87,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -882,6 +883,25 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
public Calendar due() {
return getTimestamp();
}
/**
* Add all transient action for this build
*
*/
protected List<Action> createTransientActions() {
Vector<Action> ta = new Vector<Action>();
for (TransientBuildActionFactory tpaf : TransientBuildActionFactory.all())
ta.addAll(Util.fixNull(tpaf.createFor(this)));
return ta;
}
@Override
public synchronized List<Action> getActions() {
List<Action> actions = new Vector<Action>(super.getActions());
//add transient actions too
actions.addAll(createTransientActions());
return actions;
}
/**
* Builds up a set of variable names that contain sensitive values that
......
package hudson.model;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import jenkins.model.Jenkins;
import java.util.Collection;
/**
* Extension point for inserting transient {@link Action}s into {@link AbstractBuild}s.
*
* To register your implementation, put {@link Extension} on your subtype.
*
* @author Lucie Votypkova
* @since 1.458
* @see Action
*/
public abstract class TransientBuildActionFactory implements ExtensionPoint {
/**
* Creates actions for the given build.
*
* @param project for which the action objects are requested. Never null.
* @return Can be empty but must not be null.
*/
public abstract Collection<? extends Action> createFor(AbstractBuild target);
/**
* Returns all the registered {@link TransientBuildActionFactory}s.
*/
public static ExtensionList<TransientBuildActionFactory> all() {
return Jenkins.getInstance().getExtensionList(TransientBuildActionFactory.class);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册