Skip to content

Instantly share code, notes, and snippets.

@Dispader
Last active October 24, 2021 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dispader/02a2141e3a8bfb35448c767c82c5d8be to your computer and use it in GitHub Desktop.
Save Dispader/02a2141e3a8bfb35448c767c82c5d8be to your computer and use it in GitHub Desktop.
Jenkins Script Console code to configure a private Docker Registry (Hub)
import jenkins.model.Jenkins
import org.jenkinsci.plugins.docker.workflow.declarative.GlobalConfig
def global = Jenkins.instance.getDescriptorByType(GlobalConfig.class)
global.dockerLabel = 'A_LABEL_FOR_YOUR_REGISTRY'
import org.jenkinsci.plugins.docker.commons.credentials.DockerRegistryEndpoint
def registry = new DockerRegistryEndpoint('YOUR_DOCKER_REGISTRY', 'YOUR_JENKINS_CREDENTIAL_ID_FOR_THE_REGISTRY')
global.registry = registry
@Dispader
Copy link
Author

Updated for the new Jenkins Workflow configuration classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment