Skip to content

Instantly share code, notes, and snippets.

@Dispader
Last active October 24, 2021 04:32
Show Gist options
  • Select an option

  • Save Dispader/02a2141e3a8bfb35448c767c82c5d8be to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
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