2

I would like to tag my git commits as they are deployed to the various environments in my concourse pipeline with the name of the environment. For example, in my UAT deployment job, I would like to do something like:

- 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

This would seem like a common -or at least simple, thing to do however the value of the 'tag' parameter can only be the path to a file -there is no option to pass a constant/literal value.

I see two possible solutions but none of them seems 'simple' enough:

  1. Create a file myself, but to do that (ideally?) I wish there were some kind of file resource that I could use to create the file.
  2. The last alternative would be to create a custom task, and even there I was struggling to find a way to pass the name of the tag as a parameter.

Any suggestions on what would be the best way to accomplish my goal in the simplest way, or alternatively how to implement options 1 or 2?

Thanks!

ebar
  • 21
  • 3
  • I think I found how to do #2 using task parameters: https://github.com/pivotalservices/concourse-pipeline-samples/tree/master/concourse-pipeline-patterns/parameterized-pipeline-tasks. Any other suggestions still much welcome. – ebar Dec 18 '17 at 18:36

1 Answers1

1

The reason that tag takes in a file is so that you can dynamically set the tag of the commit based on information you imply during the course of the pipeline.

So, the best way I can see to do something like this would be workflow #2 that you described above.

So you would want something like this:

- 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
Josh Zarrabi
  • 1,054
  • 7
  • 15