Filter job by tag not working – regexp possibly unsupported?

note: config version is 2.1

In my workflows, I have filters applied to determine which jobs are ran. I want a publish job (seen below) to only run when a tag is pushed. I had this working before on a much simpler regex, but wanted a comprehensive regexp for semver. We may make tags like v1-preview, 0.0.1, 0.0.1-preview, etc. It validates fine using circleci config validate, and the regexp works great on regexr.com. I was led to believe this regexp would be compatible with circleci since I got it from a CircleCI blog article.

Note, the following snippet is actually the “compiled” 2.0 configuration that I got from within circleci’s configuration tab.

    - Publish to MavenCentral:
        filters:
          tags:
            only: /(?<=^[Vv]|^)(?:(?<major>(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?<minor>(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?<patch>(?:0|[1-9](?:(?:0|[1-9])+)*))(?:-(?<prerelease>(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*)))*))?(?:[+](?<build>(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+)))*))?)$/
          branches:
            ignore: /.*/
        requires:
        - Build
        context: pi

The original 2.1 is below, where I’m utilizing a scalar var:

            - 'Publish to MavenCentral':
                  context: pi
                  requires:
                      - 'Dependencies'
                  filters:
                      tags:
                          only: *semVerRegExp # allow publish tag matches any semVer
                      branches:
                          ignore: /.*/ # ignore all branch builds

Is my regexp unsupported or have I done something obviously wrong?

I’m not sure we support named backreferences there. Can you link me the blog post so I can see if we posted conflicting info?

1 Like

Sure – IMO the support was inferred (at the very end).

I will roll mine back to something more naive without the named references.

Awesome, thanks! I’ll mark this solved then.

1 Like

:+1: For future googlers, removing named backreferences works.

semVerRegExp: &semVerRegExp
                /^(\d|[1-9]\d*)\.(\d|[1-9]\d*)\.(\d|[1-9]\d*)(-(0|[1-9A-Za-z-][0-9A-Za-z-]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9A-Za-z-][0-9A-Za-z-]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/

It handles major.minor.build-prerelease+buildmetadata:

  • 0.0.1
  • 0.0.1+3
  • 0.0.1-preview
  • 0.0.1-preview+1

(No support for prefixed v, but that’s awfully easy to add)

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.