Class GlobalVariable
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
EnvActionImpl.Binder
,ParamsVariable
,RunWrapperBinder
Note:
This extension point was designed for a handful of variables defined by generic Pipeline plugins.
If you find yourself implementing this in a domain-specific plugin,
you are probably doing too much work and harming usability in the process.
For example, there will be no Snippetizer
integration except to list its name and help text.
Variables will also not generally be compatible with Declarative Pipeline,
and may not work at all in alternate FlowExecution
implementations.
It is also all too easy to introduce security vulnerabilities for variables implemented using Groovy code.
Just because you can does not mean you should.
If at all possible, limit your plugin to implementing plain Step
s.
Should have a view named help
offering usage.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic GlobalVariable
Finds a particular variable by name.static Iterable<GlobalVariable>
Returns all the registeredGlobalVariable
s for some context.static Iterable<GlobalVariable>
Returns all the registeredGlobalVariable
s for some context.abstract String
getName()
Defines the name of the variable.abstract Object
Gets or creates the singleton value of the variable.
-
Field Details
-
ALL
Deprecated.useforRun(hudson.model.Run<?, ?>)
instead
-
-
Constructor Details
-
GlobalVariable
public GlobalVariable()
-
-
Method Details
-
getName
Defines the name of the variable.- Returns:
- a Java identifier
-
getValue
Gets or creates the singleton value of the variable. If the object is stateful, and the state should not be managed externally (such as with aRunAction2
), then the implementation is responsible for saving it in theScript.getBinding()
.- Parameters:
script
- the script we are running- Returns:
- a POJO or
GroovyObject
- Throws:
Exception
- if there was any problem creating it (will be thrown up to the script)- See Also:
-
forRun
Returns all the registeredGlobalVariable
s for some context.- Parameters:
run
- seeGlobalVariableSet.forRun(hudson.model.Run<?, ?>)
- Returns:
- a possibly empty list
-
forJob
Returns all the registeredGlobalVariable
s for some context.- Parameters:
job
- seeGlobalVariableSet.forJob(hudson.model.Job<?, ?>)
- Returns:
- a possibly empty list
-
byName
Finds a particular variable by name.- Parameters:
name
- seegetName()
run
- seeGlobalVariableSet.forRun(hudson.model.Run<?, ?>)
- Returns:
- the first matching variable, or null if there is none
-
forRun(hudson.model.Run<?, ?>)
instead