大厅CI,git标签具有恒定值

问题描述 投票:0回答:1

我想标记我的git提交,因为它们被部署到我的大厅管道中的各种环境中,并带有环境名称。例如,在我的UAT部署工作中,我想做的事情如下:

- put: master-resource <-- a git resource
  params:
    repository: master <-- the resource local directory
    tag: 'uat'
    force: true <-- replace the tag, if it already exists
    tag_only: true

这似乎是一个普通的 - 或者至少是简单的事情,但是'tag'参数的值只能是文件的路径 - 没有传递常量/文字值的选项。

我看到两种可能的解决方案,但它们似乎都不够“简单”:

  1. 自己创建一个文件,但要做到这一点(理想情况下?)我希望有一些文件资源可用于创建文件。
  2. 最后一种方法是创建一个自定义任务,即使在那里,我也在努力寻找一种方法来将标签的名称作为参数传递。

有关以最简单的方式实现目标的最佳方式的建议,或者如何实施选项1或2的任何建议?

谢谢!

concourse
1个回答
0
投票

tag接收文件的原因是您可以根据您在管道过程中暗示的信息动态设置提交的标记。

因此,我可以看到做这样的事情的最佳方式是您在上面描述的工作流程#2。

所以你会想要这样的东西:

- task: generate-git-tag
  params:
    TAG: {{some-passed-in-tag}}
  config:
    platform: linux
    image_resource:
      type: docker-image
      source:
        repository: ruby

    outputs:
    - name: tag-file

    params:
      TAG:

    run:
      path: /bin/bash
      args: 
      - -c
      - | 
        echo "${TAG}" >> tag-file/tag.txt

- put: master-resource <-- a git resource
  params:
    repository: master <-- the resource local directory
    tag: tag-file/tag.txt
    force: true <-- replace the tag, if it already exists
    tag_only: true
© www.soinside.com 2019 - 2024. All rights reserved.