public abstract class GlobalVariable extends Object implements ExtensionPoint
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.
GlobalVariableSet
ExtensionPoint.LegacyInstancesAreScopedToHudson
Modifier and Type | Field and Description |
---|---|
static Iterable<GlobalVariable> |
ALL
Deprecated.
use
forRun(hudson.model.Run<?, ?>) instead |
Constructor and Description |
---|
GlobalVariable() |
Modifier and Type | Method and Description |
---|---|
static GlobalVariable |
byName(String name,
Run<?,?> run)
Finds a particular variable by name.
|
static Iterable<GlobalVariable> |
forJob(Job<?,?> job)
Returns all the registered
GlobalVariable s for some context. |
static Iterable<GlobalVariable> |
forRun(Run<?,?> run)
Returns all the registered
GlobalVariable s for some context. |
abstract String |
getName()
Defines the name of the variable.
|
abstract Object |
getValue(CpsScript script)
Gets or creates the singleton value of the variable.
|
@Deprecated public static final Iterable<GlobalVariable> ALL
forRun(hudson.model.Run<?, ?>)
instead@Nonnull public abstract String getName()
@Nonnull public abstract Object getValue(@Nonnull CpsScript script) throws Exception
RunAction2
),
then the implementation is responsible for saving it in the Script.getBinding()
.script
- the script we are runningGroovyObject
Exception
- if there was any problem creating it (will be thrown up to the script)CpsScript.getProperty(java.lang.String)
@Nonnull public static Iterable<GlobalVariable> forRun(@CheckForNull Run<?,?> run)
GlobalVariable
s for some context.run
- see GlobalVariableSet.forRun(hudson.model.Run<?, ?>)
@Nonnull public static Iterable<GlobalVariable> forJob(@CheckForNull Job<?,?> job)
GlobalVariable
s for some context.job
- see GlobalVariableSet.forJob(hudson.model.Job<?, ?>)
@CheckForNull public static GlobalVariable byName(@Nonnull String name, @CheckForNull Run<?,?> run)
name
- see getName()
run
- see GlobalVariableSet.forRun(hudson.model.Run<?, ?>)
Copyright © 2016–2020. All rights reserved.