Reputation: 1058
As per the document,
Running "git tag" without arguments also lists all tags. The pattern is a shell wildcard (i.e., matched using fnmatch(3)). Multiple patterns may be given; if any of them matches, the tag is shown.
there are multiple tags in the repository and I want to list out only two sets of pattern in Jenkins git params.
Jenkins Git Parameter plugins are used to filter the "git tag -l {pattern}" and the pattern is based on fnmatch.
Example tag DEV2.3.4 ST2.4.6 SIT2.1.6
I just to filter out the DEV and ST tag. I tried a few different patterns.
git tag -l '(?:ST|DEV)\*'$/
git tag -l '/^DEV[0-9]+(\.[0-9]+)*$/'
git tag -l '@(DEV*|ST*)'
Could you help me out?
Upvotes: 1
Views: 858
Reputation: 66243
As @torek already notes: A 'regex' is not a 'pattern' (aka. 'glob'). But you can emulate the OR (|
) of a regex using multiple pattern because
[...] Multiple patterns may be given; if any of them matches, the tag is shown.
So this would select both DEV*
and ST*
tags:
git tag --list 'DEV*' 'ST*'
Upvotes: 1
Reputation: 487883
The crucial part of your quote above is:
The pattern is a shell wildcard (i.e., matched using fnmatch(3)).
Shell wildcards match with *
, ?
, and [...]
only.1 They are implicitly rooted at both ends. For instance, the pattern a*z
matches abcz
, axyz
, and az
but not azy
(doesn't end with z
) nor baz
(doesn't start with a
). In shell wildcard patterns, question marks match any character, asterisks match zero or more of any character, and bracketed expressions match those characters. You can get all the DEV
s with DEV*
, and all the ST
s with ST*
, but there is no syntax to match both.
1The C library fnmatch
function takes flags that modify its behavior, and on systems with a GNU fnmatch, you can get some extended forms including the @(pattern1|pattern2)
you were attempting. But Git doesn't set the flag that enables this.
Upvotes: 2