如何在dsl中使用jenkins插件作为用户名和密码?
我是jenkins的新手,我正在尝试使用凭据插件在dsl中使用凭据 template.xml如何在dsl中使用jenkins插件作为用户名和密码?,jenkins,jenkins-plugins,jenkins-groovy,jenkins-job-dsl,Jenkins,Jenkins Plugins,Jenkins Groovy,Jenkins Job Dsl,我是jenkins的新手,我正在尝试使用凭据插件在dsl中使用凭据 template.xml <com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl> <scope>GLOBAL</scope> <id>PROD</id> <description>prod credentials</descri
<com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
<scope>GLOBAL</scope>
<id>PROD</id>
<description>prod credentials</description>
<username>prod</username>
<password>{{ encrypted_password_prod }}</password
</com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
错误:
22:11:16致命:凭据“PROD”的类型为“用户名和密码”
其中“org.jenkinsci.plugins.plaincredentials.StringCredentials”是
期望
您可以将凭据放入Jenkins密钥库(Jenkins->credentials->System->Global credentials->Add credentials),然后使用withCredentials块在管道中引用它们,如下所示:
node {
withCredentials([usernameColonPassword(credentialsId: 'mylogin', variable: 'USERPASS')]) {
sh '''
set +x
curl -u "$USERPASS" https://private.server/ > output
'''
}
}
此处的更多信息:您可以将凭据放入Jenkins密钥库(Jenkins->credentials->System->Global credentials->Add credentials),然后使用withCredentials块在管道中引用它们,如下所示:
node {
withCredentials([usernameColonPassword(credentialsId: 'mylogin', variable: 'USERPASS')]) {
sh '''
set +x
curl -u "$USERPASS" https://private.server/ > output
'''
}
}
更多信息请点击此处: