API 插件,为各种与 Docker 相关的插件提供通用共享功能。
ToolInstallationDockerImageExtractor 扩展点,用于从任务中获取 Docker 镜像关系这允许用户配置一组端点/凭据,并在所有与 Docker 相关的插件中使用它,从而使配置更加 DRY。
典型用法请参阅 Docker Pipeline Plugin。
以下示例演示如何在声明式流水线中绑定 Docker 主机/守护进程凭据:
pipeline {
agent any
tools {
// a bit ugly because there is no `@Symbol` annotation for the DockerTool
// see the discussion about this in PR 77 and PR 52:
// https://github.com/jenkinsci/docker-commons-plugin/pull/77#discussion_r280910822
// https://github.com/jenkinsci/docker-commons-plugin/pull/52
'org.jenkinsci.plugins.docker.commons.tools.DockerTool' '18.09'
}
environment {
DOCKER_CERT_PATH = credentials('id-for-a-docker-cred')
}
stages {
stage('foo') {
steps {
sh "docker version" // DOCKER_CERT_PATH is automatically picked up by the Docker client
}
}
}
}
1.15 及更早版本