gradle和groovy有点新事物,试图使用以下任务:http://bmuschko.github.io/gradle-docker-docker-plugin/docs/groovydoc/grovydoc/com/bmuschko/gradle/gradle/gradle-/docker/tasks/image/dockerpushimage.html
作为folows:
task pushImageDev(type: DockerPushImage) {
imageName "xxxxxx:5000/${project.name}-${appEnviroment}:${version}"
registryCredentials {
email = 'none@your.business'
url = 'xxxxxx:5000'
username = 'xxxxxx'
password = 'xxxxxx'
}
}
,但我一直得到...
Could not find method registryCredentials() for arguments [build_21ymvy7kfomjn3daqwpuika10$_run_closure8$_closure18@dd69c19] on task ':pushImageDev' of type com.bmuschko.gradle.docker.tasks.image.DockerPushImage
我相信您只能在docker
任务配置中使用registryCredentials
方法,而不是在自定义任务中,例如
docker {
registryCredentials {
url = 'https://gcr.io'
username = '_json_key'
password = file('keyfile.json").text
}
}
如果要创建一个自定义任务,则可能必须创建一个dockerregistrycredentials的实际实例,例如
task pushImageDev(type: DockerPushImage) {
imageName "xxxxxx:5000/${project.name}-${appEnviroment}:${version}"
registryCredentials(new DockerRegistryCredentials(...));
}
原因是 registryCredentials {...}
是dockerextension.groovy中定义的扩展名,它不适用于自定义任务。它不是类registryCredentials
的固定器DockerPushImage
。
也有效的是嵌套注册表凭据调用docker
在自定义任务中,尽管我不确定为什么:
task pushImageDev(type: DockerPushImage) {
appEnviroment = 'dev'
imageName "xxxxxx/${project.name}-${appEnviroment}:${version}"
docker {
registryCredentials {
username = "${nexusUsername}"
password = "${nexusPassword}"
}
}
}