java.lang.Object
org.jenkinsci.plugins.ParameterizedRemoteTrigger.pipeline.Handle
All Implemented Interfaces:
Serializable

public class Handle extends Object implements 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 Details

  • Method Details

    • isQueued

      public boolean isQueued() throws IOException, InterruptedException
      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

      public boolean isFinished() throws IOException, InterruptedException
      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

      public String getConfiguredJobNameOrUrl()
      Returns:
      the name or URL of the remote job as configured in the job/pipeline.
    • getJobName

      @CheckForNull public String getJobName()
    • getJobFullName

      @CheckForNull public String getJobFullName()
    • getJobDisplayName

      @CheckForNull public String getJobDisplayName()
    • getJobFullDisplayName

      @CheckForNull public String getJobFullDisplayName()
    • getJobUrl

      @CheckForNull public String getJobUrl()
    • getQueueId

      @CheckForNull public String getQueueId()
      Returns:
      the id of the remote job on the queue.
    • getBuildUrl

      @CheckForNull public URL 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

      @NonNull public RemoteBuildInfo getBuildInfo()
      Gets the current build info of the remote job, containing build status and build result.
      Returns:
      RemoteBuildInfo the build info
    • getBuildStatus

      @NonNull public RemoteBuildStatus getBuildStatus()
      Gets the current build status of the remote job.
      Returns:
      RemoteBuildStatus the build status
    • updateBuildStatus

      @NonNull public RemoteBuildStatus updateBuildStatus() throws IOException, InterruptedException
      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, InterruptedException
      Updates 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

      public void setBuildInfo(RemoteBuildInfo buildInfo)
    • getBuildResult

      @NonNull public Result getBuildResult()
      Gets the current build result of the remote job.
      Returns:
      Result the build result
    • lastLog

      @NonNull public String 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

      public String toString()
      Overrides:
      toString in class Object
    • help

      public static String 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.