【问题标题】:How to share tasks between jobs? [duplicate]如何在工作之间共享任务? [复制]
【发布时间】:2017-12-02 12:17:37
【问题描述】:

我有一个任务想在多个作业中重复使用,但我不想为每个作业重复任务配置。对我来说最好的方法是什么?

例子:

jobs:
- name: build
  plan:
    - get: git-branch
      trigger: true
    - task: get-build-tag  # <---- duplicate of below
      config: {} # truncated for brevity
    - task: build-image
      file: some-stuff-to-do-with-get-build-tag
- name: test
  plan:
  - get: git-branch
    trigger: true
  - task: get-build-tag # <---- duplicate of above
    config: {} # truncated for brevity
  - task: run-tests
    file: also-to-do-with-get-build-tag

请注意那些将此问题标记为duplicate 的人:Concourse 团队指示我在此处发布此问题,特别是有关 Concourse 配置的问题。如果配置从 YAML 更改为其他内容,尽管与 YAML 无关,这篇文章仍然可以作为参考。

【问题讨论】:

  • @Anthon 见我上面的编辑。
  • 是否有人指示您发布此问题与 nothing 是否可以重复。我不确定您为什么要进行该编辑,“注释”之后的所有内容都与您的问题或编程无关。因此,编辑是不合适的,会分散您的问题并降低其质量。即使假设这个问题作为重复问题被关闭,它也不会消失,所以如果他们寻找concourse,人们仍然可以找到它。对于碰巧使用 YAML 进行配置的每个程序,没有必要对锚点有单独的答案

标签: yaml concourse


【解决方案1】:

您正在寻找的是 YAML 锚点。

这是您的管道中的样子:

# This is not part of concourse semantics but we allow
# extra keys to support anchoring
# https://github.com/concourse/concourse/issues/116
additional_tasks: 
- &get-build-tag
  task: get-build-tag
  config: {}

jobs:
- name: build
  plan:
    - get: git-branch
      trigger: true
    - *get-build-tag 
    - task: build-image
      file: some-stuff-to-do-with-get-build-tag
- name: test
  plan:
  - get: git-branch
    trigger: true
  - *get-build-tag
  - task: run-tests
    file: also-to-do-with-get-build-tag

如果您想了解我们如何在我们用于对大厅团队进行测试的管道之一中执行此操作的示例,您可以查看 here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 2011-04-27
    • 1970-01-01
    相关资源
    最近更新 更多