Search code examples
gitconcourseconcourse-git-resource

concourse git-resource : tag_filter and tag_regex not working


I have a list of git tags

0.0.1
0.0.1-rc.0
0.0.1-rc.1
0.1.0
0.10.0
0.10.1-rc.0
0.11.0
0.11.1-rc.0
0.12.0
0.12.1-rc.0
0.13.0
0.13.1-hotfix.0
0.13.1-rc.0
0.14.0
0.14.1-rc.0
0.15.0
0.15.1-rc.0
0.16.0
0.16.1-rc.0
0.17.0
0.17.1-rc.0
0.18.0
0.18.1-hotfix.0

from these tags I want to get only the following tags:

0.0.1, 0.1.0, 0.10.0 , 0.11.0, 0.12.0, 0.13.0, 0.14.0, 0.15.0, 0.16.0, 0.17.0, 0.18.0, 0.10.0

I declared my resource as follow :

- name: git-filtered
  type: git
  icon: bitbucket
  source:
    uri: ssh://((git-url))
    private_key: ((git-key))
    branch: master
    fetch_tags: true
    tag_regex: "[0-9]+.[0-9]+.[0-9]+"

and I have tried all these solutions :

#    tag_regex: "[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+"
#    tag_filter: "[0-9].??.[0-9]"
#    tag_filter: "*([0-9])\\.*([0-9])\\.*([0-9])"
#    tag_filter: "*([0-9])\.*([0-9])\.*([0-9])"
#    tag_filter: "*([0-9]).*([0-9]).*([0-9])"
#    tag_regex: "[0-9]+\\.[0-9]+\\.[0-9]+"
#    tag_regex: "[0-9]+\.[0-9]+\.[0-9]+"
#    tag_regex: "[0-9]\.[0-9]\.[0-9]"
#    tag_regex: "[0123456789]+.[0123456789]+.[0123456789]+"
#    tag_filter: "[0-9].??.[0-9]"

none of them seems to filter the digits as I want (digits.digits.digits).

I have used this line as reference to build my filter : https://github.com/concourse/git-resource/blob/master/assets/check#L168.

Any idea ?


Solution

  • I found what was wrong.

    The tag_regex was introduced since the version 1.11.0 of git-resource.

    Our concourse server uses an older version of git resource. So I forced the version as follow :

      - name: git
        type: docker-image
        source:
          repository: concourse/git-resource
          tag: "1.12.0" 
    

    and now the filter using regex is working properly :

    tag_regex: '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+'