Class DisplayURLContext
java.lang.Object
org.jenkinsci.plugins.displayurlapi.DisplayURLContext
- All Implemented Interfaces:
Closeable
,AutoCloseable
Holds contextual information that can be used when generating an URL for display. On the current thread, each context
is layered with the most specific context information being provided when queried.
-
Method Summary
Modifier and TypeMethodDescriptionGets the custom attribute value for the current URL generation..Adds custom attributes to the context.void
close()
Gets theQueue.Executable
associated with the current URL generation (if any).executable
(Queue.Executable executable) Uses the suppliedQueue.Executable
to fill in as much of the context as possible.Job<?,
?> job()
Gets theJob
associated with the current URL generation (if any).Uses the suppliedJob
to fill in as much of the context as possible.static DisplayURLContext
open()
Opens aDisplayURLContext
for the current thread.static DisplayURLContext
open
(boolean guessPlugin) Opens aDisplayURLContext
for the current thread.plugin()
Gets the best guess as to thePluginWrapper
requesting the current URL generation (if any).plugin
(PluginWrapper plugin) Overrides the inferred plugin tha is requesting the URL to be generated with the supplied plugin.Run<?,
?> run()
Gets theRun
associated with the current URL generation (if any).Uses the suppliedRun
to fill in as much of the context as possible.task()
Gets theQueue.Task
associated with the current URL generation (if any).task
(Queue.Task task) Uses the suppliedQueue.Task
to fill in as much of the context as possible.
-
Method Details
-
open
Opens aDisplayURLContext
for the current thread.- Parameters:
guessPlugin
- try to infer the current plugin (resource intensive as requires a stack trace and class loading). Usefalse
if you know the caller will always be Jenkins core.- Returns:
- the
DisplayURLContext
.
-
open
Opens aDisplayURLContext
for the current thread.- Returns:
- the
DisplayURLContext
.
-
task
Uses the suppliedQueue.Task
to fill in as much of the context as possible. If the task implementsJob
then thejob()
will also be set. Prefer callingjob(Job)
if you know the task is aJob
already.- Parameters:
task
- the task.- Returns:
this
for method chaining.
-
executable
Uses the suppliedQueue.Executable
to fill in as much of the context as possible. The owning task of the executable will be used to set thetask()
. If the task implementsRun
then therun()
andjob()
will also be set. Prefer callingrun(Run)
if you know the executable is aRun
already.- Parameters:
executable
- the executable.- Returns:
this
for method chaining.
-
job
Uses the suppliedJob
to fill in as much of the context as possible. If the job is also aQueue.Task
thentask()
will also be set.- Parameters:
job
- the job.- Returns:
this
for method chaining.
-
run
Uses the suppliedRun
to fill in as much of the context as possible. TheRun.getParent()
will be set to thejob()
andtask()
as appropriate. If the run is also aQueue.Executable
thenexecutable()
will also be set.- Parameters:
run
- the run.- Returns:
this
for method chaining.
-
plugin
Overrides the inferred plugin tha is requesting the URL to be generated with the supplied plugin.- Parameters:
plugin
- the plugin.- Returns:
this
for method chaining.
-
attribute
Adds custom attributes to the context.- Parameters:
name
- the name of the attribute.value
- the value of the attribute (may benull
).- Returns:
this
for method chaining.
-
task
Gets theQueue.Task
associated with the current URL generation (if any).- Returns:
- the
Queue.Task
associated with the current URL generation ornull
if none.
-
executable
Gets theQueue.Executable
associated with the current URL generation (if any).- Returns:
- the
Queue.Executable
associated with the current URL generation ornull
if none.
-
job
Gets theJob
associated with the current URL generation (if any).- Returns:
- the
Job
associated with the current URL generation ornull
if none.
-
run
Gets theRun
associated with the current URL generation (if any).- Returns:
- the
Run
associated with the current URL generation ornull
if none.
-
plugin
Gets the best guess as to thePluginWrapper
requesting the current URL generation (if any).- Returns:
- the
PluginWrapper
most closely associated with the current URL generation ornull
if initiated by Jenkins core.
-
attribute
Gets the custom attribute value for the current URL generation..- Parameters:
name
- the name of the attribute.- Returns:
- the value or
null
.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-