Jenkins Groovy 管道中的凭据错误

Jenkins Groovy Error For Credentials in Pipeline

我有一个脚本,其中的一部分是:

              stage('plan') {
                withCredentials([
                    [$class: 'AmazonWebServicesCredentialsBinding', credentialsId: aws_cred_id,
                      accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
                    string(credentialsId: 'xxxxcredx', variable: 'TF_VAR_token') {
                  docker.withRegistry('https://registry-1.docker.io/', 'dockerhub-creds') {

现在,当这是 Jenkins 中的 运行 时,我看到输出为:

java.lang.IllegalArgumentException: Expected named arguments but got [{credentialsId=xxxxcredx, variable=TF_VAR_token}, org.jenkinsci.plugins.workflow.cps.CpsClosure2]

如何修复或修改我的脚本以不让 jenkins 实际选择凭据和 var 值时出现此错误。

我觉得应该是这样的(查不到)

凭据绑定文档:https://www.jenkins.io/doc/pipeline/steps/credentials-binding/

withCredentials([
    aws(credentialsId: aws_cred_id, accessKeyVariable: 'AWS_ACCESS_KEY_ID', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'),
    string(credentialsId: 'xxxxcredx', variable: 'TF_VAR_token'),
]) {
    docker.withRegistry ...
}