如何教我的Jenkisfile在此设置中通过基本身份验证登录?
我正在为我的Jenkins构建使用自定义docker镜像.
如文档here中所述,我定义了一个docker agent,如下所示:
pipeline {
agent {
docker {
image 'registry.az1:5043/maven-proto'
registryUrl 'https://registry.az1'
args '-v /var/jenkins_home/.m2:/root/.m2'
}
}
options {
timeout(time: 1,unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr:'10'))
}
stages {
stage ('Build') {
steps{
sh ...
}
}
stage ('Test') {
steps {
sh ...
}
}
stage ('Deploy') {
steps {
sh ...
}
}
}
post {
always {
echo 'Clean up workspace'
deleteDir()
}
}
}
如果我使用以下代理设置:
pipeline {
agent {
docker.withRegistry('https://registry.az1','registry_login'){
image 'registry.az1:5043/maven-proto'
registryUrl 'https://registry.az1'
args '-v /var/jenkins_home/.m2:/root/.m2'
}
}
管道的执行失败,出现以下异常:
WorkflowScript: 3: Too many arguments for map key "withRegistry" @ line 3,column 16.
docker.withRegistry('https://registry.az1','registry_login'){
^
WorkflowScript: 3: Invalid agent type "withRegistry" specified. Must be one of [docker,dockerfile,label,any,none] @ line 3,column 16.
docker.withRegistry('https://registry.az1','registry_login'){
^