Class DockerSwarmClient

java.lang.Object
io.jenkins.plugins.swarmcloud.api.DockerSwarmClient
All Implemented Interfaces:
Closeable, AutoCloseable

public class DockerSwarmClient extends Object implements Closeable
Client for Docker Swarm API operations.
  • Constructor Details

    • DockerSwarmClient

      public DockerSwarmClient(@NonNull String dockerHost, @Nullable String credentialsId)
  • Method Details

    • getSwarmVersion

      @NonNull public String getSwarmVersion()
    • getNodeCount

      public int getNodeCount()
    • createService

      @NonNull public String createService(@NonNull String agentName, @NonNull SwarmAgentTemplate template, @NonNull String jenkinsUrl, @NonNull String secret, @Nullable String networkName)
      Creates a Docker Swarm service for a Jenkins agent.
      Parameters:
      agentName - Unique name for the agent
      template - Agent template configuration
      jenkinsUrl - URL for agents to connect to Jenkins
      secret - Secret for agent authentication
      networkName - Docker network to attach (optional)
      Returns:
      Service ID
    • createService

      @NonNull public String createService(@NonNull String agentName, @NonNull SwarmAgentTemplate template, @NonNull String jenkinsUrl, @Nullable String networkName)
      Overloaded method for backwards compatibility.
    • removeService

      public void removeService(@NonNull String serviceId)
      Removes a Docker Swarm service. Handles 404 (not found) gracefully - if service is already gone, that's fine.
    • getService

      @Nullable public com.github.dockerjava.api.model.Service getService(@NonNull String serviceId)
      Gets information about a service.
    • getServiceLogs

      @Nullable public String getServiceLogs(@NonNull String serviceId, int tailLines)
      Gets logs from a service.
    • listJenkinsServices

      @NonNull public List<com.github.dockerjava.api.model.Service> listJenkinsServices()
      Lists all Jenkins agent services.
    • listServicesForCloud

      @NonNull public List<com.github.dockerjava.api.model.Service> listServicesForCloud(@NonNull String cloudName)
      Lists services for a specific cloud.
    • getServiceTasks

      @NonNull public List<com.github.dockerjava.api.model.Task> getServiceTasks(@NonNull String serviceId)
      Gets tasks for a service.
    • isServiceRunning

      public boolean isServiceRunning(@NonNull String serviceId)
      Checks if a service is running (has at least one running task).
    • createConfig

      @NonNull public String createConfig(@NonNull String name, @NonNull byte[] data)
    • deleteConfig

      public void deleteConfig(@NonNull String configId)
    • listConfigs

      @NonNull public List<com.github.dockerjava.api.model.Config> listConfigs()
    • createSecret

      @NonNull public String createSecret(@NonNull String name, @NonNull byte[] data)
    • deleteSecret

      public void deleteSecret(@NonNull String secretId)
    • listSecrets

      @NonNull public List<com.github.dockerjava.api.model.Secret> listSecrets()
    • getDockerClient

      public com.github.dockerjava.api.DockerClient getDockerClient()
      Gets the underlying Docker client for advanced operations.
    • getDockerHost

      public String getDockerHost()
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException