Class RemoteBuildConfiguration

java.lang.Object
hudson.tasks.BuildStepCompatibilityLayer
hudson.tasks.Builder
org.jenkinsci.plugins.ParameterizedRemoteTrigger.RemoteBuildConfiguration
All Implemented Interfaces:
ExtensionPoint, Describable<Builder>, BuildStep, Serializable, SimpleBuildStep

public class RemoteBuildConfiguration extends Builder implements SimpleBuildStep, Serializable
Author:
Maurice W.
See Also:
  • Constructor Details

    • RemoteBuildConfiguration

      @DataBoundConstructor public RemoteBuildConfiguration()
  • Method Details

    • readResolve

      protected Object readResolve()
    • setTrustAllCertificates

      @DataBoundSetter public void setTrustAllCertificates(boolean trustAllCertificates)
    • setOverrideTrustAllCertificates

      @DataBoundSetter public void setOverrideTrustAllCertificates(boolean overrideTrustAllCertificates)
    • setAbortTriggeredJob

      @DataBoundSetter public void setAbortTriggeredJob(boolean abortTriggeredJob)
    • setMaxConn

      @DataBoundSetter public void setMaxConn(int maxConn)
    • setRemoteJenkinsName

      @DataBoundSetter public void setRemoteJenkinsName(String remoteJenkinsName)
    • setRemoteJenkinsUrl

      @DataBoundSetter public void setRemoteJenkinsUrl(String remoteJenkinsUrl)
    • setAuth2

      @DataBoundSetter public void setAuth2(Auth2 auth)
    • setParameters2

      @DataBoundSetter public void setParameters2(JobParameters parameters2)
    • setShouldNotFailBuild

      @DataBoundSetter public void setShouldNotFailBuild(boolean shouldNotFailBuild)
    • setPreventRemoteBuildQueue

      @DataBoundSetter public void setPreventRemoteBuildQueue(boolean preventRemoteBuildQueue)
    • setHttpGetReadTimeout

      @DataBoundSetter public void setHttpGetReadTimeout(int readTimeout)
    • setHttpPostReadTimeout

      @DataBoundSetter public void setHttpPostReadTimeout(int readTimeout)
    • setPollInterval

      @DataBoundSetter public void setPollInterval(int pollInterval)
    • setBlockBuildUntilComplete

      @DataBoundSetter public void setBlockBuildUntilComplete(boolean blockBuildUntilComplete)
    • setJob

      @DataBoundSetter public void setJob(String job)
    • setToken

      @DataBoundSetter public void setToken(String token)
    • setParameters

      @DataBoundSetter public void setParameters(String parameters)
    • setEnhancedLogging

      @DataBoundSetter public void setEnhancedLogging(boolean enhancedLogging)
    • setDisabled

      @DataBoundSetter public void setDisabled(boolean disabled)
    • setUseJobInfoCache

      @DataBoundSetter public void setUseJobInfoCache(boolean useJobInfoCache)
    • setUseCrumbCache

      @DataBoundSetter public void setUseCrumbCache(boolean useCrumbCache)
    • getParameterMap

      public Map<String,String> getParameterMap(BuildContext context) throws AbortException
      Throws:
      AbortException
    • evaluateEffectiveRemoteHost

      @NonNull public RemoteJenkinsServer evaluateEffectiveRemoteHost(BasicBuildContext context) throws IOException
      Tries to identify the effective Remote Host configuration based on the different parameters like remoteJenkinsName and the globally configured remote host, remoteJenkinsURL which overrides the address locally or job which can be a full job URL.
      Parameters:
      context - the context of this Builder/BuildStep.
      Returns:
      RemoteJenkinsServer a RemoteJenkinsServer object, never null.
      Throws:
      AbortException - if no server found and remoteJenkinsUrl empty.
      MalformedURLException - if remoteJenkinsName no valid URL or job an URL but nor valid.
      IOException
    • getLock

      public Semaphore getLock(String addr)
    • findRemoteHost

      @Nullable @CheckForNull public RemoteJenkinsServer findRemoteHost(String displayName)
      Lookup up the globally configured Remote Jenkins Server based on display name
      Parameters:
      displayName - Name of the configuration you are looking for
      Returns:
      A deep-copy of the RemoteJenkinsServer object configured globally
    • removeTrailingSlashes

      protected static String removeTrailingSlashes(String string)
    • removeQueryParameters

      protected static String removeQueryParameters(String string)
    • removeHashParameters

      protected static String removeHashParameters(String string)
    • failBuild

      protected void failBuild(Exception e, PrintStream logger) throws IOException
      Convenience function to mark the build as failed. It's intended to only be called from this.perform().
      Parameters:
      e - exception that caused the build to fail.
      logger - build listener.
      Throws:
      IOException - if the build fails and shouldNotFailBuild is not set.
    • abortRemoteTask

      public void abortRemoteTask(RemoteJenkinsServer remoteServer, Handle handle, BuildContext context) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • perform

      public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException, IllegalArgumentException
      Specified by:
      perform in interface BuildStep
      Overrides:
      perform in class BuildStepCompatibilityLayer
      Throws:
      InterruptedException
      IOException
      IllegalArgumentException
    • isStepDisabled

      public boolean isStepDisabled(PrintStream printStream)
    • perform

      public void perform(Run<?,?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException
      Triggers the remote job and, waits until completion if blockBuildUntilComplete is set.
      Specified by:
      perform in interface SimpleBuildStep
      Throws:
      InterruptedException - if any thread has interrupted the current thread.
      IOException - if there is an error retrieving the remote build data, 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.
    • performTriggerAndGetQueueId

      public Handle performTriggerAndGetQueueId(@NonNull BuildContext context) throws IOException, InterruptedException
      Triggers the remote job, identifies the queue ID and, returns a Handle to this remote execution.
      Parameters:
      context - the context of this Builder/BuildStep.
      Returns:
      Handle to further tracking of the remote build status.
      Throws:
      IOException - if there is an error triggering the remote job.
      InterruptedException - if any thread has interrupted the current thread.
    • performWaitForBuild

      public void performWaitForBuild(BuildContext context, Handle handle) throws IOException, InterruptedException
      Checks the remote build status and, waits for completion if blockBuildUntilComplete is set.
      Parameters:
      context - the context of this Builder/BuildStep.
      handle - the handle to the remote execution.
      Throws:
      InterruptedException - if any thread has interrupted the current thread.
      IOException - if any HTTP error or business logic error
    • updateBuildInfo

      @NonNull public RemoteBuildInfo updateBuildInfo(@NonNull RemoteBuildInfo buildInfo, @NonNull BuildContext context) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • generateEffectiveRemoteBuildURL

      protected static URL generateEffectiveRemoteBuildURL(URL remoteBuildURL, String effectiveRemoteServerAddress) throws AbortException
      Throws:
      AbortException
    • doGet

      public ConnectionResponse doGet(String urlString, BuildContext context, RemoteBuildStatus remoteBuildStatus) throws IOException, InterruptedException
      Orchestrates all calls to the remote server. Also takes care of any credentials or failed-connection retries.
      Parameters:
      urlString - the URL that needs to be called.
      context - the context of this Builder/BuildStep.
      remoteBuildStatus - the build status of a remote build.
      Returns:
      JSONObject a valid JSON object, or null.
      Throws:
      InterruptedException - if any thread has interrupted the current thread.
      IOException - if any HTTP error occurred.
    • isAbortTriggeredJob

      public boolean isAbortTriggeredJob()
    • getMaxConn

      public int getMaxConn()
    • getRemoteJenkinsName

      public String getRemoteJenkinsName()
      Returns:
      the configured remote Jenkins name. That's the ID of a globally configured remote host.
    • getRemoteJenkinsUrl

      public String getRemoteJenkinsUrl()
      Returns:
      the configured remote Jenkins URL. This is not necessarily the effective Jenkins URL, e.g. if a full URL is specified for job!
    • getHttpGetReadTimeout

      public int getHttpGetReadTimeout()
    • getHttpPostReadTimeout

      public int getHttpPostReadTimeout()
    • getOverrideAuth

      public boolean getOverrideAuth()
      Deprecated.
      since 2.3.0-SNAPSHOT - use getAuth2() instead.
      Returns:
      true, if the authorization is overridden in the job configuration, otherwise false.
    • getAuth2

      public Auth2 getAuth2()
    • getShouldNotFailBuild

      public boolean getShouldNotFailBuild()
    • getPreventRemoteBuildQueue

      public boolean getPreventRemoteBuildQueue()
    • getPollInterval

      public int getPollInterval(RemoteBuildStatus remoteBuildStatus)
    • getBlockBuildUntilComplete

      public boolean getBlockBuildUntilComplete()
    • getJob

      public String getJob()
      Returns:
      the configured job value. Can be a job name or full job URL.
    • getToken

      public String getToken()
    • getEnhancedLogging

      public boolean getEnhancedLogging()
    • getParameters2

      public JobParameters getParameters2()
    • getConnectionRetryLimit

      public int getConnectionRetryLimit()
    • isDisabled

      public boolean isDisabled()
    • generateJobUrl

      protected static String generateJobUrl(RemoteJenkinsServer remoteServer, String jobNameOrUrl) throws AbortException
      Throws:
      AbortException
    • getDescriptor

      Specified by:
      getDescriptor in interface Describable<Builder>
      Overrides:
      getDescriptor in class Builder
    • isUseCrumbCache

      public boolean isUseCrumbCache()
    • isUseJobInfoCache

      public boolean isUseJobInfoCache()
    • getTrustAllCertificates

      public boolean getTrustAllCertificates()
    • getOverrideTrustAllCertificates

      public boolean getOverrideTrustAllCertificates()