CircleCI 2.1:在参数中声明的变量出现未知变量错误。

huangapple go评论57阅读模式
英文:

CircleCI 2.1 : Unknown variable(s) error for variables declared in parameters

问题

我在我的工作下定义了以下内容。但当我通过 Web 用户界面运行时,所有在参数下定义的变量都显示为未知变量。这里有什么问题?

terraform_import_resources:
    docker:
      - image: myecrrepo/ansibleterraformpython3:tf0.12.18-1
    parameters:
      aws_ssoadmin_permission_set:
        type: string
        default: "AWSAdministratorAccess"
      aws_ssoadmin_permission_set_params:
        type: string
        default: "arn:aws:sso:::permissionSet/xxxxxx,arn:aws:sso:::instance/ssoins-xxxx"
      aws_ssoadmin_account_assignment:
        type: string
        default: "AWSAdministratorAccess"
      aws_ssoadmin_account_assignment_params:
        type: string
        default: "xxxxxx"
    steps:
      - checkout
      - attach_workspace:
          at: ~/
      - add_ssh_keys: *add_ssh_keys_infra_modules
      - run: *infra_modules_checkout
      - run:
          name: Run Terraform import
          command: |
            . ~/.env
            ansible --version
            terraform --version
            TAG_NAMES=`git log -1 --pretty=%B | perl -nle 'print $1 if /\((.*)\)/'`
            echo $TAG_NAMES 
            terraform import aws_ssoadmin_permission_set.<<pipeline.parameters.aws_ssoadmin_permission_set>> <<pipeline.parameters.aws_ssoadmin_permission_set_params>>
            terraform import aws_ssoadmin_account_assignment.<<pipeline.parameters.aws_ssoadmin_account_assignment>> <<pipeline.parameters.aws_ssoadmin_account_assignment_params>>
英文:

I have the below defined under my job. But when I run thru the web UI, I get Unknown variable(s) for all the variables defined under the parameter. What is wrong here?

terraform_import_resources:
    docker:
      - image: myecrrepo/ansibleterraformpython3:tf0.12.18-1
    parameters:
      aws_ssoadmin_permission_set:
        type: string
        default: &quot;AWSAdministratorAccess&quot;
      aws_ssoadmin_permission_set_params:
        type: string
        default: &quot;arn:aws:sso:::permissionSet/xxxxxx,arn:aws:sso:::instance/ssoins-xxxx&quot;
      aws_ssoadmin_account_assignment:
        type: string
        default: &quot;AWSAdministratorAccess&quot;
      aws_ssoadmin_account_assignment_params:
        type: string
        default: &quot;xxxxxx&quot;
    steps:
      - checkout
      - attach_workspace:
          at: ~/
      - add_ssh_keys: *add_ssh_keys_infra_modules
      - run: *infra_modules_checkout
      - run:
          name: Run Terraform import
          command: |
            . ~/.env
            ansible --version
            terraform --version
            TAG_NAMES=`git log -1 --pretty=%B | perl -nle &#39;print $1 if /\((.*)\)/&#39;`
            echo $TAG_NAMES 
            terraform import aws_ssoadmin_permission_set.&lt;&lt; pipeline.parameters.aws_ssoadmin_permission_set&gt;&gt; &lt;&lt; pipeline.parameters.aws_ssoadmin_permission_set_params &gt;&gt;
            terraform import aws_ssoadmin_account_assignment.&lt;&lt; pipeline.parameters.aws_ssoadmin_account_assignment &gt;&gt; &lt;&lt; pipeline.parameters.aws_ssoadmin_account_assignment_params &gt;&gt;

答案1

得分: 0

在作业/命令的参数中,应该使用以下形式:

&lt;&lt; parameters.aws_ssoadmin_permission_set &gt;&gt;

而不是

&lt;&lt; pipeline.parameters.aws_ssoadmin_permission_set &gt;&gt;

参考文档:https://circleci.com/docs/reusing-config/#parameter-syntax

英文:

So, I found that for a parameter in a job/command it should be used as:

&lt;&lt; parameters.aws_ssoadmin_permission_set &gt;&gt;

instead of

&lt;&lt; pipeline.parameters.aws_ssoadmin_permission_set &gt;&gt;

Doc for reference: https://circleci.com/docs/reusing-config/#parameter-syntax

huangapple
  • 本文由 发表于 2023年5月24日 21:35:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76324135.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定