Use glob patterns in bitbucket pipelines for matching semantic tags

Viewed 623

I'd like to trigger different pipelines by matching tag semantics in Bitbucket pipelines. Globbing seems to work only for * matchings, but other features from glob patterns seem to not be taken:

+([0-9]).+([0-9]).+([0-9])

for instance. This should match every tags like 1.0.0, but not anything else.

Any idea on how to achieve this?

I'd prefer not to trigger any pipeline, make the check in the pipeline script and exit early.

pipelines:
  tags:
    +([0-9]).+([0-9]).+([0-9]):
       name: Pipeline for new semantic tag
       script:
         - ...

Note: I also tried putting the glob between ", but that doesn't work either.

2 Answers

There's no regex support for tags, it's all simple globs

Does this work for you?

  • '*.*.*'
  • build-*
  • build-*.*.*
  • release-*
  • release-*.*.*

Not ideal, but if you can't get by with pattern matching you could fail the step if it doesn't match your regex...

something like this should work:

[[ $BITBUCKET_TAG =~ ^+([0-9]).+([0-9]).+([0-9])$ ]] && echo "valid tag" || exit 1
Related