【发布时间】:2021-09-13 20:14:25
【问题描述】:
我有一个脚本,其中一部分是:
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 值。
【问题讨论】:
-
我发现这个问题*.com/questions/36931114/… 可能类似.. 但我仍然不知道如何修复我的脚本
-
我在示例中看不到在闭包
{ ... }内使用string(...)的能力。我认为您必须将其移至withCredentials([ ... ])。 jenkins.io/doc/pipeline/steps/credentials-binding
标签: jenkins groovy syntax jenkins-pipeline jenkins-groovy