-1

我正在尝试在大厅中创建一个管道,它将触发远程分支上的 github 更新,并使用该分支来计划、应用和销毁 terraform 部署。

- name: terraform-repo
  type: git
  icon: github
  source:
    uri: https://github.com/....

#docker image
- name: terraform-0-13-7
  type: registry-image
  source:
    repository: hashicorp/terraform
    tag: 0.13.7

jobs:
- name: terraform-deplyoment
  plan:
  - get: terraform-0-13-7
  - get: terraform-repo
    trigger: true

  - task: terraform-init
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - init

  - task: terraform-plan
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - plan
        params:
          variable1: "test"
          variable2: "test2"

触发管道时,会在大厅 GUI 上出错,指出 var 不可用。我在语法上做错了吗?

4

1 回答 1

0

params它们作为环境变量暴露给任务,因此您应该将它们用作输入变量

  - task: terraform-plan
    image: terraform-0-13-7
    config:
      inputs:
      - name: terraform-repo
      outputs:
      - name: terraform-repo
      platform: linux
      run:
        path: terraform
        dir: terraform-repo
        args:
        - plan
        params:
          TF_VAR_variable1: "test"
          TF_VAR_variable2: "test2"

于 2021-12-03T17:12:49.937 回答