当前,我们在Jenkins groovy(脚本化管道)中使用cf login
命令,如下所示:
def login(url, uName, password, org, space){
CONNECT = sh (
script: "cf login -a ${url} -u \"${uName}\" -p \"${password}\" -o ${org} -s ${space}",
returnStatus: true
) == 0
}
但是现在Jenkins配置了以下凭据:
因此,我们不需要用户名/密码即可连接到Pivotal Cloud铸造厂
如何在脚本化管道中使用这些凭据?
答案 0 :(得分:2)
def login(url, org, space){
withCredentials([usernamePassword(credentialsId: 'AppsManager', usernameVariable: 'uName', passwordVariable: 'password')]) {
CONNECT = sh (
script: "cf login -a ${url} -u \"${uName}\" -p \"${password}\" -o ${org} -s ${space}",
returnStatus: true
).trim()
}
}