Class BuildCardExtension
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<BuildCardExtension>
-
- au.com.centrumsystems.hudson.plugin.buildpipeline.extension.BuildCardExtension
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<BuildCardExtension>
,Comparable<BuildCardExtension>
- Direct Known Subclasses:
StandardBuildCard
public abstract class BuildCardExtension extends AbstractDescribableImpl<BuildCardExtension> implements ExtensionPoint, Comparable<BuildCardExtension>
This class is an extension point for a plugin to provide their own behavior for the 'build cards' that show up in the build pipeline plugin.
This base class encapsulates the logic for how builds can be re-run and how the upstream build is found, allowing subclasses to override this behavior.
In addition, this class also defines the look-and-feel of the build cards so that they can be overridden. These are defined in the following .jelly files:
- buildCardTemplate.jelly
- buildCardHelpers.jelly
- Author:
- dalvizu
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description BuildCardExtension()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ExtensionList<BuildCardExtension>
all()
int
compareTo(BuildCardExtension o)
protected List<Action>
filterActions(List<Action> actions)
Filter out the list of actions so that it only includesParametersAction
and CauseActions, removing the UserIdAction from the CauseAction's list of Causes.protected CauseAction
filterOutUserIdCause(CauseAction causeAction)
Filter outCause.UserIdCause
from the givenCauseAction
.abstract long
getIndex()
Return an index to where this should be displayed, relative to other optionsprotected static ParametersAction
mergeParameters(ParametersAction base, ParametersAction overlay)
From parameterized trigger plugin src/main/java/hudson/plugins/parameterizedtrigger/BuildTriggerConfig.javaint
rerunBuild(String externalizableId)
Re-run the build known by the given Run externalizeableIdprotected AbstractBuild<?,?>
retrieveBuild(int buildNo, AbstractProject<?,?> project)
Given an AbstractProject and a build number the associated AbstractBuild will be retrieved.protected List<hudson.plugins.parameterizedtrigger.AbstractBuildParameters>
retrieveUpstreamProjectTriggerConfig(AbstractProject<?,?> project, AbstractBuild<?,?> upstreamBuild)
Used to retrieve the parameters from the upstream project build trigger relative to the given downstream projectprotected int
triggerBuild(AbstractProject<?,?> triggerProject, AbstractBuild<?,?> upstreamBuild, Action buildParametersAction)
Schedules a build to start.int
triggerManualBuild(ItemGroup pipelineContext, Integer upstreamBuildNumber, String triggerProjectName, String upstreamProjectName)
Trigger a manual build-
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
-
-
-
Method Detail
-
all
public static ExtensionList<BuildCardExtension> all()
- Returns:
- all known
BuildCardExtension
s
-
getIndex
public abstract long getIndex()
Return an index to where this should be displayed, relative to other options- Returns:
- the index - lower appears first in the list
-
compareTo
public int compareTo(BuildCardExtension o)
- Specified by:
compareTo
in interfaceComparable<BuildCardExtension>
-
rerunBuild
public int rerunBuild(String externalizableId)
Re-run the build known by the given Run externalizeableId- Parameters:
externalizableId
- - a Run externalizableId- Returns:
- the integer of the next Run
-
filterActions
protected List<Action> filterActions(List<Action> actions)
Filter out the list of actions so that it only includesParametersAction
and CauseActions, removing the UserIdAction from the CauseAction's list of Causes. We want to include CauseAction because that includes upstream cause actions, which are inherited in downstream builds. We do not want to inherit the UserId cause, because the user initiating a retry may be different than the user who originated the upstream build, and so should be re-identified. We do not want to inherit any other CauseAction because that will result in duplicating actions from publishers, and builders from previous builds corrupting the retriggered build.- Parameters:
actions
- a collection of build actions.- Returns:
- a collection of build actions with all UserId causes removed.
-
filterOutUserIdCause
protected CauseAction filterOutUserIdCause(CauseAction causeAction)
Filter outCause.UserIdCause
from the givenCauseAction
. We want to do this because re-run will want to contribute its ownCause.UserIdCause
, not copy it from the previous run.- Parameters:
causeAction
- the causeAction to remove UserIdCause from- Returns:
- a causeAction with UserIdCause removed
-
triggerManualBuild
public int triggerManualBuild(ItemGroup pipelineContext, Integer upstreamBuildNumber, String triggerProjectName, String upstreamProjectName)
Trigger a manual build- Parameters:
pipelineContext
- - the context of the calling pipeline, used to find projects in the pipelineupstreamBuildNumber
- - the build number of the upstream buildtriggerProjectName
- - the name of the project being manually triggeredupstreamProjectName
- - the name of the project in the upstream build- Returns:
- the build number of the triggered manual build
-
triggerBuild
protected int triggerBuild(AbstractProject<?,?> triggerProject, AbstractBuild<?,?> upstreamBuild, Action buildParametersAction)
Schedules a build to start. The build will take an upstream build as its Cause and a set of ParametersAction from the upstream build.- Parameters:
triggerProject
- - Schedule a build to start on this AbstractProjectupstreamBuild
- - The upstream AbstractBuild that will be used as a Cause for the triggerProject's build.buildParametersAction
- - The upstream ParametersAction that will be used as an Action for the triggerProject's build.- Returns:
- next build number
-
retrieveUpstreamProjectTriggerConfig
protected List<hudson.plugins.parameterizedtrigger.AbstractBuildParameters> retrieveUpstreamProjectTriggerConfig(AbstractProject<?,?> project, AbstractBuild<?,?> upstreamBuild)
Used to retrieve the parameters from the upstream project build trigger relative to the given downstream project- Parameters:
project
- the downstream projectupstreamBuild
- the upstream project build- Returns:
- the trigger config relative to the given downstream project
-
mergeParameters
protected static ParametersAction mergeParameters(ParametersAction base, ParametersAction overlay)
From parameterized trigger plugin src/main/java/hudson/plugins/parameterizedtrigger/BuildTriggerConfig.java- Parameters:
base
- One of the two parameters to merge.overlay
- The other parameters to merge- Returns:
- Result of the merge.
-
retrieveBuild
protected AbstractBuild<?,?> retrieveBuild(int buildNo, AbstractProject<?,?> project)
Given an AbstractProject and a build number the associated AbstractBuild will be retrieved.- Parameters:
buildNo
- - Build numberproject
- - AbstractProject- Returns:
- The AbstractBuild associated with the AbstractProject and build number.
-
-