codemagic-docs
codemagic-docs copied to clipboard
Missing details about syntax for tags and branch patterns
As per discussion in Slack : https://codemagicio.slack.com/archives/CEKE2KZ37/p1649930771811679
In the documentation, there are some examples of using pattern
s to specify the name of tags or branches that trigger a workflow, for instance : https://docs.codemagic.io/yaml/yaml-getting-started/#triggering
Unfortunately the examples are quite "basic" , and are either:
- a particular branch/tag
- or a wildcard
*
The assumption is that this is some sort of glob
syntax, but as it's not really standardized, it's hard to know which features of glob
are supported or not.
When we need to filter a bit more finely, this becomes a bit hard.
Naively, I assumed I'd be able to use a pattern like v+([0-9]).+([0-9]).+([0-9])
, to include tags with a name like v{1 or more number}.{1 or more number}.{1 or more number}
... but this doesn't work.
As a workaround, I ended up with combining inclusion and exclusion filters
tag_patterns:
# build for tags that look like `vX.X.X`
- pattern: "v*.*.*"
include: true
# but ignore if there is a `-` somewhere (for instance `v2.1.3-rc`)
- pattern: "*-*"
include: false
but this doesn't quite express the real goal here.
Could we have more details about what level of glob
support is available ?
Thanks !
Thanks @tsimbalar. This is actually an issue for me right now. I'm not sure how to make my tag triggers work.
I use semantic versioning for tags (e.g. v1.2.0-rc.1 for release candidate versions and v1.2.0 for release versions). I then trigger a build for beta when a release candidate is tagged or I trigger a prod build when a release version is tagged
I'm not sure how to filter for release candidate version and release version tags
It would be helpful if there were more examples
I'm having a similar problem.
I have a 2 workflows. One for prod builds and one for QA builds. I’m trying to setup a proper triggering ruleset to start builds. Basically what I want to do is,
- When a tag in the format of
v1.0.0-prod
is created, the prod workflow would run. - When a tag in the format of
v1.0.0-qa
is created, the QA workflow would run.
I added the below to my codemagic.yaml file.
triggering:
events:
- tag
branch_patterns:
- pattern: "master"
- include: true
source: true
tag_patterns:
- pattern: "v*.*.*-prod"
- include: true
But in my tests, I’ve found that, if I create the tags in basically any format (some samples below), still the build would trigger!
v1.0.0.1-prod
- with an extra digit.
v1.0.1-test
- undefined name at the end.
new-tag
- completely different than the pattern defined in codemagic.yaml
Not sure how to restrict the triggers to only conform to my exact vX.X.X-prod format.
i would also like to have more infos about how those patterns work if they are not regex compliant. I had a major f%ck up because of a wrong branch name ended up in an ugly release version name in Apple Connect which i cant even delete on Apple site.
We use fnmatch module for pattern matching. Regex obviously is much richer, supporting repetitions, and (in ERE) alternation and specific numbers of repetitions.
@Isuru-Nanayakkara Seems the configuration is incorrect in your yaml:
triggering: events: - tag branch_patterns: - pattern: "master" - include: true source: true tag_patterns: - pattern: "v*.*.*-prod" - include: true
Instead it should be as follows:
triggering:
events:
- tag
branch_patterns:
- pattern: 'master'
include: true
source: true
tag_patterns:
- pattern: 'v*.*.*-prod'
include: true
Hi all, thanks for the feedback! We've now switched to a library that allows defining more advanced patterns for matching branch and tag names.