我要注入Azure凭据以及其他内容。 我如何使这个工作?
stage('provision') {
withCredentials([
[azureServicePrincipal('azsrvprincipaldev')],
[$class: 'FileBinding', credentialsId: 'id_rsa', variable: 'RSA_PATH'],
[$class: 'FileBinding', credentialsId: 'id_rsa.pub', variable: 'RSA_PUB_PATH']
]) {
sh './jenkins.sh'
}
}
错误:
java.lang.ClassCastException:
org.jenkinsci.plugins.credentialsbinding.impl.BindingStep.bindings expects
class org.jenkinsci.plugins.credentialsbinding.MultiBinding but received class java.util.ArrayList
Caused: java.lang.IllegalArgumentException: Could not instantiate
{bindings=[[@azureServicePrincipal(<anonymous>=azsrvprincipaldev)],
{$class=FileBinding, credentialsId=id_rsa, variable=RSA_PATH},
{$class=FileBinding, credentialsId=id_rsa.pub, variable=RSA_PUB_PATH}]}
for BindingStep(bindings:
MultiBinding{AzureCredentialsBinding(credentialsId: String,
clientIdVariable?: String, clientSecretVariable?: String,
subscriptionIdVariable?: String, tenantIdVariable?: String)
...
答案 0 :(得分:2)
不要将azureServicePrincipal()
与其他[]
一起包裹。
这应该工作
stage('provision') {
withCredentials([
azureServicePrincipal('azsrvprincipaldev'),
[$class: 'FileBinding', credentialsId: 'id_rsa', variable: 'RSA_PATH'],
[$class: 'FileBinding', credentialsId: 'id_rsa.pub', variable: 'RSA_PUB_PATH']
]) {
sh './jenkins.sh'
}
}