在jenkins中引用credentials
jenkins配置
Pipeline引用
withCredentials([usernamePassword(credentialsId: 'ameng', passwordVariable: 'Password', usernameVariable: 'Username')]) {
sh 'docker login --u$Username -p$Uassword registry.meng.com'
}
credentials() ,可以获取jenkins中预定义的凭证明文内容
withCredentials([ usernamePassword(credentialsId: 'DB_USER', usernameVariable: 'DB_USER_NAME', passwordVariable: 'DB_USER_PASSWORD'), usernamePassword(credentialsId: 'MDB_USER', usernameVariable: 'MDB_USER_NAME', passwordVariable: 'MDB_USER_PASSWORD') ]){
方法1:
DOCKER_REGISTER_CREDS = credentials('docker-repo-creds') //docker registry凭证
KUBE_CONFIG_LOCAL = credentials('k8s-kube-config') //测试环境的kube凭证
KUBE_CONFIG_PROD = "" //credentials('prod-k8s-config') //生产环境的kube凭证
标签:passwordVariable,DB,credentialsId,USER,credentials,jenkins,引用 From: https://blog.csdn.net/lisanmengmeng/article/details/143023068