Class DockerCredentialsHelper
java.lang.Object
io.jenkins.plugins.swarmcloud.config.DockerCredentialsHelper
Helper class for working with Docker server credentials.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault Docker Hub registry URL for official and user images. -
Method Summary
Modifier and TypeMethodDescriptionstatic com.github.dockerjava.api.model.AuthConfigcreateAuthConfig(String credentialsId, String registryAddress) Creates AuthConfig for Docker registry from credentials.static StringextractRegistryAddress(String imageName) Extracts registry address from Docker image name.static ListBoxModelfillCredentialsIdItems(Item context, String dockerHost) Fills a ListBoxModel with available Docker server credentials.static StringgetCaCertificate(org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials credentials) Gets the CA certificate from credentials.static StringgetClientCertificate(org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials credentials) Gets the client certificate from credentials.static StringgetClientKey(org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials credentials) Gets the client key from credentials.static booleanhasCredentialsAccess(Item item) Checks if the current user has permission to access credentials for the given item.static org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentialslookupCredentials(String credentialsId, String dockerHost) Looks up Docker server credentials by ID.static com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentialslookupRegistryCredentials(String credentialsId) Looks up username/password credentials for Docker registry authentication.
-
Field Details
-
DOCKER_HUB_REGISTRY_URL
Default Docker Hub registry URL for official and user images.- See Also:
-
-
Method Details
-
hasCredentialsAccess
Checks if the current user has permission to access credentials for the given item.- Parameters:
item- The context item (may be null for global context)- Returns:
- true if the user has sufficient permissions
-
lookupCredentials
@Nullable public static org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials lookupCredentials(@Nullable String credentialsId, @NonNull String dockerHost) Looks up Docker server credentials by ID.- Parameters:
credentialsId- The credentials IDdockerHost- The Docker host URL (for domain matching)- Returns:
- The credentials, or null if not found
-
fillCredentialsIdItems
@NonNull public static ListBoxModel fillCredentialsIdItems(@Nullable Item context, @NonNull String dockerHost) Fills a ListBoxModel with available Docker server credentials.- Parameters:
context- The context item (for permission checks)dockerHost- The Docker host URL (for domain matching)- Returns:
- ListBoxModel with credentials
-
getCaCertificate
@Nullable public static String getCaCertificate(@Nullable org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials credentials) Gets the CA certificate from credentials. -
getClientCertificate
@Nullable public static String getClientCertificate(@Nullable org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials credentials) Gets the client certificate from credentials. -
getClientKey
@Nullable public static String getClientKey(@Nullable org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials credentials) Gets the client key from credentials. -
lookupRegistryCredentials
@Nullable public static com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials lookupRegistryCredentials(@Nullable String credentialsId) Looks up username/password credentials for Docker registry authentication.- Parameters:
credentialsId- The credentials ID- Returns:
- The credentials, or null if not found
-
createAuthConfig
@Nullable public static com.github.dockerjava.api.model.AuthConfig createAuthConfig(@Nullable String credentialsId, @Nullable String registryAddress) Creates AuthConfig for Docker registry from credentials.- Parameters:
credentialsId- The credentials ID for registry authenticationregistryAddress- The registry address (e.g., "docker.io", "gcr.io")- Returns:
- AuthConfig or null if credentials not found
-
extractRegistryAddress
Extracts registry address from Docker image name.Examples:
- "myregistry.com/image:tag" -> "myregistry.com"
- "gcr.io/project/image:tag" -> "gcr.io"
- "image:tag" -> "https://index.docker.io/v1/" (Docker Hub)
- "myuser/myimage:v1" -> "https://index.docker.io/v1/" (Docker Hub)
- "myregistry.com:5000/image:tag" -> "myregistry.com:5000"
- Parameters:
imageName- The Docker image name- Returns:
- The registry address
-