kosta
kosta

Reputation: 4740

Dynamically setting docker image tag from semver when using docker-image-resource in concourse

I have the following semver setup:

- name: version 
  type: semver
  source:
    driver: gcs
    bucket: my-ci
    json_key: ((my.serviceaccount))
    key: version/version.txt
    initial_version: 0.0.0

In my publishjob, I have the following:

 name: publish
  serial_groups: [version]
  plan:
  - get: version
    passed: [build]  
    trigger: true

So, basically the publish job is triggered after build job is passed (version updated)

Now, in the publish job I am creating a docker image and pushing it to gcr.

  - put: my-gcr
    params:
      additional_tags: my/ci/tags
      build: mycode
    get_params: {skip_download: true}

Here, the image is correctly tagged based on the values in the tags file. However, I want to set these values dynamically based on the current version which can be retreived following this:

https://concoursetutorial.com/miscellaneous/versions-and-buildnumbers/#display-version

How can I use this version number to tag my docker image?

Upvotes: 1

Views: 1265

Answers (1)

kosta
kosta

Reputation: 4740

I solved it using the following code:

- put: artifacts
    params:
      additional_tags: version/number
      build: mycode
    get_params: {skip_download: true}

Upvotes: 1

Related Questions