Class TestServerTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.jenkinsci.gradle.plugins.jpi2.TestServerTask
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

@CacheableTask public abstract class TestServerTask extends org.gradle.api.DefaultTask
Task that launches a Jenkins server and terminates after success or first error.

It does so by spawning a nested Gradle build that runs the real :server / :hplRun task, so the verification exercises exactly the launch path users rely on.

Cacheable: a successful run produces a marker file. If the declared inputs are unchanged, Gradle can restore the marker from cache and skip launching Jenkins. The modeled inputs are:

  • the plugin files synced for the server and the Jenkins runtime classpath;
  • files referenced from the plugin's HPL (testHplRun only);
  • the forwarded init scripts — content via getInitScriptFiles() and order/identity via getInitScriptPaths();
  • the project's build logic that can change the nested build: build & settings scripts, gradle.properties, version catalogs, and buildSrc sources (see getBuildConfigFiles());
  • the forwarded Gradle flags and system/project properties.

Cacheability boundary. Because the nested build re-evaluates the whole project, its inputs cannot be captured exhaustively from here. Changes to build logic outside the modeled set are not guaranteed to invalidate the cache, notably: included builds located outside the project tree, environment variables, ~/.gradle/gradle.properties, the Gradle or wrapper version, and dynamic dependency versions resolved from the network. When in doubt, run with --rerun-tasks to force a fresh launch.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Named

    org.gradle.api.Named.Namer
  • Field Summary

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.provider.Property<Boolean>
     
    abstract org.gradle.api.file.ConfigurableFileCollection
     
    abstract org.gradle.api.provider.Property<Boolean>
     
    abstract org.gradle.api.provider.Property<Boolean>
     
    abstract org.gradle.api.provider.Property<String>
     
    abstract org.gradle.api.provider.ListProperty<String>
     
    abstract org.gradle.api.file.ConfigurableFileCollection
     
    abstract org.gradle.api.provider.ListProperty<String>
     
    abstract org.gradle.api.provider.Property<String>
     
    abstract org.gradle.api.file.ConfigurableFileCollection
     
    abstract org.gradle.api.provider.Property<Boolean>
     
    abstract org.gradle.api.provider.Property<Boolean>
     
    abstract org.gradle.api.file.ConfigurableFileCollection
     
    abstract org.gradle.api.provider.Property<PortAllocationService>
     
    abstract org.gradle.api.provider.Property<Boolean>
     
    abstract org.gradle.api.provider.MapProperty<String,String>
     
    abstract org.gradle.api.file.ConfigurableFileCollection
     
    abstract org.gradle.api.provider.Property<Boolean>
     
    abstract org.gradle.api.provider.Property<Boolean>
     
    abstract org.gradle.api.provider.Property<String>
     
    abstract org.gradle.api.provider.Property<String>
     
    abstract org.gradle.api.file.RegularFileProperty
     
    abstract org.gradle.api.provider.MapProperty<String,String>
     
    void
    Launches a nested Gradle build, streams its output, and fails the task if Jenkins does not report a successful start within the configured timeout.

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.gradle.api.Task

    doNotTrackState, notCompatibleWithConfigurationCache
  • Constructor Details

    • TestServerTask

      public TestServerTask()
  • Method Details

    • getRootDir

      @Input public abstract org.gradle.api.provider.Property<String> getRootDir()
      Returns:
      root directory of the plugin project, used as the working directory for the spawned Gradle process
    • getGradleExecutable

      @Input public abstract org.gradle.api.provider.Property<String> getGradleExecutable()
      Returns:
      path to the gradlew executable to invoke for the nested build
    • getJavaHome

      @Input public abstract org.gradle.api.provider.Property<String> getJavaHome()
      Returns:
      path to the JDK passed to the spawned Gradle via -Dorg.gradle.java.home
    • getInitScriptPaths

      @Input public abstract org.gradle.api.provider.ListProperty<String> getInitScriptPaths()
      Returns:
      ordered absolute paths of the init scripts forwarded via --init-script, in the exact order they are passed. Gradle applies init scripts in command-line order, so the order (and the set of paths) is part of the cache key — reordering two scripts, or swapping one for a same-content script at a different path, changes the nested build and must invalidate the cache. Content is fingerprinted separately by getInitScriptFiles().
    • getInitScriptFiles

      @InputFiles @PathSensitive(NONE) public abstract org.gradle.api.file.ConfigurableFileCollection getInitScriptFiles()
      Returns:
      the init script files, fingerprinted for content so that editing a script invalidates the cache even when its path is unchanged. Path and ordering are captured by getInitScriptPaths(), so this collection only needs to track content (PathSensitivity.NONE).
    • getBuildConfigFiles

      @InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getBuildConfigFiles()
      Returns:
      build-logic files for the nested build's project tree: build & settings scripts (*.gradle, *.gradle.kts), gradle.properties, version catalogs (*.versions.toml), and buildSrc sources. Changes to these affect the nested build's behavior (e.g. JavaExec task args or resolved plugin versions) but are not captured by plugin-file or classpath inputs. This is best-effort, not exhaustive — see the cacheability boundary on the class javadoc.
    • getIncludedBuilds

      @Input public abstract org.gradle.api.provider.ListProperty<String> getIncludedBuilds()
      Returns:
      composite-build inclusions forwarded via --include-build
    • getOffline

      @Input public abstract org.gradle.api.provider.Property<Boolean> getOffline()
      Returns:
      true to pass --offline to the spawned Gradle
    • getBuildCacheEnabled

      @Input public abstract org.gradle.api.provider.Property<Boolean> getBuildCacheEnabled()
      Returns:
      true to pass --build-cache to the spawned Gradle
    • getRefreshDependencies

      @Input public abstract org.gradle.api.provider.Property<Boolean> getRefreshDependencies()
      Returns:
      true to pass --refresh-dependencies to the spawned Gradle
    • getContinueOnFailure

      @Input public abstract org.gradle.api.provider.Property<Boolean> getContinueOnFailure()
      Returns:
      true to pass --continue to the spawned Gradle
    • getParallelExecution

      @Input public abstract org.gradle.api.provider.Property<Boolean> getParallelExecution()
      Returns:
      true to pass --parallel to the spawned Gradle
    • getProfile

      @Input public abstract org.gradle.api.provider.Property<Boolean> getProfile()
      Returns:
      true to pass --profile to the spawned Gradle
    • getRerunTasks

      @Input public abstract org.gradle.api.provider.Property<Boolean> getRerunTasks()
      Returns:
      true to pass --rerun-tasks to the spawned Gradle
    • getDryRun

      @Input public abstract org.gradle.api.provider.Property<Boolean> getDryRun()
      Returns:
      true to pass --dry-run to the spawned Gradle
    • getSystemProperties

      @Input public abstract org.gradle.api.provider.MapProperty<String,String> getSystemProperties()
      Returns:
      system properties forwarded as -Dkey=value to the spawned Gradle, excluding internal ones
    • getProjectProperties

      @Input public abstract org.gradle.api.provider.MapProperty<String,String> getProjectProperties()
      Returns:
      project properties forwarded as -Pkey=value to the spawned Gradle, excluding internal ones
    • getServerTaskPath

      @Input public abstract org.gradle.api.provider.Property<String> getServerTaskPath()
      Returns:
      Gradle task path to run inside the spawned build (e.g. :server)
    • getPluginFiles

      @InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getPluginFiles()
      Returns:
      files that prepareServer / prepareRun would copy into the Jenkins work directory (the project's own JPI/HPL and resolved plugin dependencies). Fingerprinting these is what makes the task safely cacheable when nothing relevant has changed.
    • getJenkinsClasspath

      @Classpath public abstract org.gradle.api.file.ConfigurableFileCollection getJenkinsClasspath()
      Returns:
      classpath used to launch the embedded Jenkins server (jenkins-war).
    • getReferencedFiles

      @InputFiles @PathSensitive(RELATIVE) public abstract org.gradle.api.file.ConfigurableFileCollection getReferencedFiles()
      Returns:
      files referenced by the plugin's HPL but not bundled into getPluginFiles(): the plugin's own classes, resource directories, and bundled libraries. Required for testHplRun, where the HPL points at these paths directly; ignored (empty) for testServer, since the JPI archive already captures the same content.
    • getSuccessMarker

      @OutputFile public abstract org.gradle.api.file.RegularFileProperty getSuccessMarker()
      Returns:
      marker file written only on a successful Jenkins start so the task is cacheable.
    • getPortAllocationService

      @Internal public abstract org.gradle.api.provider.Property<PortAllocationService> getPortAllocationService()
      Returns:
      build service that allocates a free TCP port for the Jenkins test server
    • runTestServer

      public void runTestServer()
      Launches a nested Gradle build, streams its output, and fails the task if Jenkins does not report a successful start within the configured timeout.