Class BuildFlowScriptExtension
- java.lang.Object
-
- hudson.plugins.project_inheritance.projects.view.BuildFlowScriptExtension
-
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
ShellBuildFlow
public abstract class BuildFlowScriptExtension extends Object implements ExtensionPoint
This class is an extension point to add new handlers for turning certainBuilder
into executable shell scripts- Author:
- mhschroe
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description BuildFlowScriptExtension()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ExtensionList<BuildFlowScriptExtension>
all()
This method returns all extensions for this extension point.abstract void
cleanUp()
Extension counterpart ofcleanUpThread()
.static void
cleanUpThread()
The logical counterpart toinitThread()
, but called after the last external call to the script generation is done.static Map<String,String>
filterEnv(Map<String,String> params)
Static wrapper forfilterEnvironment(Map)
over all extensions.abstract void
filterEnvironment(Map<String,String> env)
Override this method to filter environment variables set at the beginning of the script.abstract List<AbstractProject<?,?>>
getDependentProjects(AbstractProject<?,?> p)
This method returns the dependent projects and will be called bygetDependentProjectsFor(AbstractProject, Map)
, so that the individual extension does not have to care about versioning.static List<AbstractProject<?,?>>
getDependentProjectsFor(AbstractProject<?,?> p, Map<String,Long> verMap)
This method returns the list of dependent projects for the given project and versioning map.abstract List<MetaScript>
getScriptsFor(File prefix, AbstractProject<?,?> project, AbstractBuild<?,?> build, Builder step, Map<String,String> env, AtomicInteger cnt)
This method asks the extension to handle the given builder and return a valid set of scripts along with some metadata of how to handle it.static List<MetaScript>
getScriptsFor(File prefix, AbstractProject<?,?> project, AbstractBuild<?,?> build, List<Builder> builders, Map<String,String> params, AtomicInteger cnt)
Uses the registeredBuildFlowScriptExtension
instances to turn the list of builders into a list ofMetaScript
instances that can be used in a script.abstract void
init()
Extension counterpart ofinitThread()
.static void
initThread()
This function is called before the first external call ofgetScriptsFor(File, AbstractProject, AbstractBuild, Builder, Map, AtomicInteger)
is initiated.
-
-
-
Method Detail
-
all
public static ExtensionList<BuildFlowScriptExtension> all()
This method returns all extensions for this extension point.- Returns:
- a list, can be empty but never null.
-
initThread
public static void initThread()
This function is called before the first external call ofgetScriptsFor(File, AbstractProject, AbstractBuild, Builder, Map, AtomicInteger)
is initiated.It is useful, because some
BuildFlowScriptExtension
s need access to a more persistent storage during the runtime of their script generation and that storage is usually aThreadLocal
field.A simple example is a script that should only be emitted once, no matter how often a property is encountered during script generation. The method itself can't make this storage available easily, without adding fields to the method signature that most extensions wouldn't even use.
-
init
public abstract void init()
Extension counterpart ofinitThread()
.
-
cleanUpThread
public static void cleanUpThread()
The logical counterpart toinitThread()
, but called after the last external call to the script generation is done.
-
cleanUp
public abstract void cleanUp()
Extension counterpart ofcleanUpThread()
.
-
filterEnv
public static Map<String,String> filterEnv(Map<String,String> params)
Static wrapper forfilterEnvironment(Map)
over all extensions.- Parameters:
params
- the environment to filter. Must be mutable.- Returns:
- the filtered environment.
-
filterEnvironment
public abstract void filterEnvironment(Map<String,String> env)
Override this method to filter environment variables set at the beginning of the script.Variables can be added, modified or removed.
- Parameters:
env
- the environment to alter. Always mutable and never null.
-
getScriptsFor
public abstract List<MetaScript> getScriptsFor(File prefix, AbstractProject<?,?> project, AbstractBuild<?,?> build, Builder step, Map<String,String> env, AtomicInteger cnt)
This method asks the extension to handle the given builder and return a valid set of scripts along with some metadata of how to handle it.If the extension does not handle that step type, it must return an empty list.
- Parameters:
prefix
- if not null, the prefix for the script files. If null, no prefix is used.project
- the project that owns the builders. Is not necessarily the parent of build.build
- the build for which the scripts should be generated. Is not necessarily a build of the given project.step
- the build to generate a script for.env
- the environment for the build script.cnt
- a counter shared between all scripts of a build, so that you unique file names can be generated more easily.- Returns:
- a list of
MetaScript
instances, may be empty, but never null.
-
getScriptsFor
public static List<MetaScript> getScriptsFor(File prefix, AbstractProject<?,?> project, AbstractBuild<?,?> build, List<Builder> builders, Map<String,String> params, AtomicInteger cnt)
Uses the registeredBuildFlowScriptExtension
instances to turn the list of builders into a list ofMetaScript
instances that can be used in a script.- Parameters:
prefix
- if not null, the prefix for the script files. If null, no prefix is used.project
- the project that owns the builders. Is not necessarily the parent of build.build
- the build for which the scripts should be generated. Is not necessarily a build of the given project.builders
- the build steps to convert.params
- the environment variables/parameters of the jobcnt
- a counter to generate unique IDs with- Returns:
- the list of scripts that are the result of conversion. May be empty, but never null.
-
getDependentProjects
public abstract List<AbstractProject<?,?>> getDependentProjects(AbstractProject<?,?> p)
This method returns the dependent projects and will be called bygetDependentProjectsFor(AbstractProject, Map)
, so that the individual extension does not have to care about versioning.- Parameters:
p
- the project to target- Returns:
- a list of projects, may be empty, but is never null.
- See Also:
getDependentProjectsFor(AbstractProject, Map)
-
getDependentProjectsFor
public static List<AbstractProject<?,?>> getDependentProjectsFor(AbstractProject<?,?> p, Map<String,Long> verMap)
This method returns the list of dependent projects for the given project and versioning map.A dependent project is one that is started by (or after) the given project as a form of flow. The generated list should be identical to the one generated in the process of creating the list of scripts.
Its main use is to allow the WebUI to enumerate all the
CommandInterpreter
instances that will be run in response to the given job starting.- Parameters:
p
- the project to target.verMap
- the versions to use.- Returns:
- a list of projects. Will always contain at least the value of p.
-
-