Class Handle
java.lang.Object
org.jenkinsci.plugins.ParameterizedRemoteTrigger.pipeline.Handle
- All Implemented Interfaces:
Serializable
A handle to the triggered remote build. This handle is used in Pipelines
to have direct access to the (correct) remote build instead of relying on
environment variables (like in a Job). This prevents issues e.g. when triggering
remote jobs in a parallel pipeline step.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHandle
(RemoteBuildConfiguration remoteBuildConfiguration, RemoteBuildInfo buildInfo, String currentItem, RemoteJenkinsServer effectiveRemoteServer, net.sf.json.JSONObject remoteJobMetadata) -
Method Summary
Modifier and TypeMethodDescriptionGets the current build info of the remote job, containing build status and build result.int
Get the build number of the remote build.Gets the current build result of the remote job.Gets the current build status of the remote job.Get the build URL of the remote build.static String
help()
This method returns a all available methods.boolean
Check if the remote job build is finished.boolean
isQueued()
Check if the remote build is still queued (not building yet).lastLog()
This method returns the log entries which resulted from the last method call to the Handle.readJsonFileFromBuildArchive
(String filename) This method reads and parses a JSON file which has been archived by the last remote build.void
setBuildInfo
(RemoteBuildInfo buildInfo) toString()
Updates the current build status of the remote job.Updates the build status of the remote build until it is finished.
-
Constructor Details
-
Handle
public Handle(@NonNull RemoteBuildConfiguration remoteBuildConfiguration, @NonNull RemoteBuildInfo buildInfo, @NonNull String currentItem, @NonNull RemoteJenkinsServer effectiveRemoteServer, @NonNull net.sf.json.JSONObject remoteJobMetadata)
-
-
Method Details
-
isQueued
Check if the remote build is still queued (not building yet).- Returns:
- true if still queued, false if already running.
- Throws:
IOException
- if there is an error retrieving the remote build number.InterruptedException
- if any thread has interrupted the current thread.
-
isFinished
Check if the remote job build is finished.- Returns:
- true if the remote job build ran and finished successfully, otherwise false.
- Throws:
IOException
- if there is an error retrieving the remote build number, or, if there is an error retrieving the remote build status, or, if there is an error retrieving the console output of the remote build, or, if the remote build does not succeed.InterruptedException
- if any thread has interrupted the current thread.
-
getConfiguredJobNameOrUrl
- Returns:
- the name or URL of the remote job as configured in the job/pipeline.
-
getJobName
-
getJobFullName
-
getJobDisplayName
-
getJobFullDisplayName
-
getJobUrl
-
getQueueId
- Returns:
- the id of the remote job on the queue.
-
getBuildUrl
Get the build URL of the remote build.- Returns:
- the URL, or null if it could not be identified (yet).
-
getBuildNumber
@NonNull public int getBuildNumber()Get the build number of the remote build.- Returns:
- the build number, or 0 if it could not be identified (yet).
-
getBuildInfo
Gets the current build info of the remote job, containing build status and build result.- Returns:
RemoteBuildInfo
the build info
-
getBuildStatus
Gets the current build status of the remote job.- Returns:
RemoteBuildStatus
the build status
-
updateBuildStatus
Updates the current build status of the remote job.- Returns:
RemoteBuildStatus
the build status- Throws:
IOException
- if there is an error retrieving the remote build number, or, if there is an error retrieving the remote build status, or, if there is an error retrieving the console output of the remote build, or, if the remote build does not succeed.InterruptedException
- if any thread has interrupted the current thread.
-
updateBuildStatusBlocking
@NonNull public RemoteBuildStatus updateBuildStatusBlocking() throws IOException, InterruptedExceptionUpdates the build status of the remote build until it is finished.- Returns:
RemoteBuildStatus
the build status- Throws:
IOException
- if there is an error retrieving the remote build number, or, if there is an error retrieving the remote build status, or, if there is an error retrieving the console output of the remote build, or, if the remote build does not succeed.InterruptedException
- if any thread has interrupted the current thread.
-
setBuildInfo
-
getBuildResult
Gets the current build result of the remote job.- Returns:
Result
the build result
-
lastLog
This method returns the log entries which resulted from the last method call to the Handle. This is a workaround since logging to the pipeline log directly does not work yet if used asynchronously.- Returns:
- The latest log entries from the last called method.
-
toString
-
help
This method returns a all available methods. This might be helpful to get available methods while developing and testing a pipeline script.- Returns:
- a string representing all the available methods.
-
readJsonFileFromBuildArchive
public Object readJsonFileFromBuildArchive(String filename) throws IOException, InterruptedException This method reads and parses a JSON file which has been archived by the last remote build. From Groovy/Pipeline code elements can be accessed directly via object.nodeC.nodeB.leafC.- Parameters:
filename
- the filename or path to the remote JSON file relative to the last builds archive folder- Returns:
- JSON structure as Object (consisting of Map, List, and primitive types), or null if not available (yet)
- Throws:
IOException
- if there is an error identifying the remote host, or if there is an error setting the authorization header, or if the request fails due to an unknown host, unauthorized credentials, or another reason.InterruptedException
- if any thread has interrupted the current thread.
-