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.voidclose()Gets theQueue.Executableassociated with the current URL generation (if any).executable(Queue.Executable executable) Uses the suppliedQueue.Executableto fill in as much of the context as possible.Job<?,?> job()Gets theJobassociated with the current URL generation (if any).Uses the suppliedJobto fill in as much of the context as possible.static DisplayURLContextopen()Opens aDisplayURLContextfor the current thread.static DisplayURLContextopen(boolean guessPlugin) Opens aDisplayURLContextfor the current thread.plugin()Gets the best guess as to thePluginWrapperrequesting 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 theRunassociated with the current URL generation (if any).Uses the suppliedRunto fill in as much of the context as possible.task()Gets theQueue.Taskassociated with the current URL generation (if any).task(Queue.Task task) Uses the suppliedQueue.Taskto fill in as much of the context as possible. 
- 
Method Details
- 
open
Opens aDisplayURLContextfor the current thread.- Parameters:
 guessPlugin- try to infer the current plugin (resource intensive as requires a stack trace and class loading). Usefalseif you know the caller will always be Jenkins core.- Returns:
 - the 
DisplayURLContext. 
 - 
open
Opens aDisplayURLContextfor the current thread.- Returns:
 - the 
DisplayURLContext. 
 - 
task
Uses the suppliedQueue.Taskto fill in as much of the context as possible. If the task implementsJobthen thejob()will also be set. Prefer callingjob(Job)if you know the task is aJobalready.- Parameters:
 task- the task.- Returns:
 thisfor method chaining.
 - 
executable
Uses the suppliedQueue.Executableto fill in as much of the context as possible. The owning task of the executable will be used to set thetask(). If the task implementsRunthen therun()andjob()will also be set. Prefer callingrun(Run)if you know the executable is aRunalready.- Parameters:
 executable- the executable.- Returns:
 thisfor method chaining.
 - 
job
Uses the suppliedJobto fill in as much of the context as possible. If the job is also aQueue.Taskthentask()will also be set.- Parameters:
 job- the job.- Returns:
 thisfor method chaining.
 - 
run
Uses the suppliedRunto 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.Executablethenexecutable()will also be set.- Parameters:
 run- the run.- Returns:
 thisfor method chaining.
 - 
plugin
Overrides the inferred plugin tha is requesting the URL to be generated with the supplied plugin.- Parameters:
 plugin- the plugin.- Returns:
 thisfor 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:
 thisfor method chaining.
 - 
task
Gets theQueue.Taskassociated with the current URL generation (if any).- Returns:
 - the 
Queue.Taskassociated with the current URL generation ornullif none. 
 - 
executable
Gets theQueue.Executableassociated with the current URL generation (if any).- Returns:
 - the 
Queue.Executableassociated with the current URL generation ornullif none. 
 - 
job
Gets theJobassociated with the current URL generation (if any).- Returns:
 - the 
Jobassociated with the current URL generation ornullif none. 
 - 
run
Gets theRunassociated with the current URL generation (if any).- Returns:
 - the 
Runassociated with the current URL generation ornullif none. 
 - 
plugin
Gets the best guess as to thePluginWrapperrequesting the current URL generation (if any).- Returns:
 - the 
PluginWrappermost closely associated with the current URL generation ornullif 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:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceCloseable
 
 -