在管道任務中指定運行時參數 (Specify runtime parameter in a pipeline task)


問題描述

在管道任務中指定運行時參數 (Specify runtime parameter in a pipeline task)

我們需要以某種方式將動態運行時參數傳遞給管道任務。例如下面的參數 APPROVAL 對於任務的每次運行都是不同的。此 APPROVAL 參數用於更改和發布編號,以便任務可以在為審計目的而創建的 Terraform 資源上標記它。

在網上搜索了一段時間但沒有找到解決方案,是這可能在大廳管道或最佳實踐中?

  ‑ task: plan‑terraform
    file: ci/concourse‑jobs/pipelines/tasks/terraform/plan‑terraform.yaml
    params:
      ENV: dev
      APPROVAL: test
      CHANNEL: Developement
      GITLAB_KEY: ((gitlab_key))
      REGION: eu‑west‑2
      TF_FOLDER: terraform/squid
    input_mapping:
      ci: ci
      tf: squid
    output_mapping:
      plan: plan
    tags:
    ‑ dev

參考解法

方法 1:

From https://concourse‑ci.org/tasks.html: ideally tasks are pure functions: given the same set of inputs, it should either always succeed with the same outputs or always fail.

A dynamic parameter would break that contract and produce different outputs from the same set of inputs. Could you possibly make APPROVAL an input? Then you'd maintain your build traceability. If it's a (file) input, you could then load it into a variable:

APPROVAL=$(cat <filename>)

(by Alastair MontgomeryBrian S)

參考文件

  1. Specify runtime parameter in a pipeline task (CC BY‑SA 2.5/3.0/4.0)

#concourse #concourse-pipeline






相關問題

進行飛行同步時的未知目標 (unknown target when doing a fly sync)

從另一個大廳到達一個大廳任務的容器 (Reach one concourse task's container from another one)

從 Concourse 克隆 Bitbucket 上的 git 存儲庫的問題 (Issues cloning a git repo on Bitbucket from Concourse)

如果作業被取消,Concourse 會阻止後台進程停止 (Concourse prevent background processes from being stopped if job is canceled)

Concourse 流水線:如何讓嵌入式腳本使流水線失敗 (Concourse Pipeline: How to have an Embedded Script Fail the Pipeline)

將構建目錄 (/dist) 從一個作業傳遞到大廳中的下一個作業 (Pass build directory (/dist) from a job to next job in concourse)

Concourse CI 找不到 kubernetes 機密 (Concourse CI can't find kubernetes secrets)

大廳工作人員“找不到文件” (Concourse Worker "file not found")

windows系統需要安裝Concourse(CI/CD) (Need to Install Concourse(CI/CD) on windows system)

在管道任務中指定運行時參數 (Specify runtime parameter in a pipeline task)

如何遍歷大廳中的數組 (How to iterate through an array in concourse)







留言討論