Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,26 @@ private boolean notMatchUseRepository(String gitUrl) {
private Set<String> getTag(GitClient gitClient, String gitUrl) throws InterruptedException {
Set<String> tagSet = new HashSet<>();
try {
Map<String, ObjectId> tags = gitClient.getRemoteReferences(gitUrl, tagFilter, false, true);

Map<String, ObjectId> tags = null;

boolean isRegex = tagFilter != null && tagFilter.startsWith("/");
tags = gitClient.getRemoteReferences(gitUrl, isRegex ? "*" : tagFilter, false, true);

Pattern pattern = null;
if (isRegex) {
pattern = Pattern.compile(tagFilter.substring(1));
}

for (String tagName : tags.keySet()) {
tagSet.add(tagName.replaceFirst(REFS_TAGS_PATTERN, ""));
tagName = tagName.replaceFirst(REFS_TAGS_PATTERN, "");
if (isRegex) {
if (pattern.matcher(tagName).matches()) {
tagSet.add(tagName);
}
} else {
tagSet.add(tagName);
}
}
} catch (GitException e) {
LOGGER.log(Level.WARNING, getCustomJobName() + " " + Messages.GitParameterDefinition_getTag(), e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div>
This parameter is used to get tag from git.<br/>
If is blank, parameter is set to "*".<br/>
Regex patterns must be prefixed with a forward slash (ie /.*).<br/>
Properly is executed command: <tt>git ls-remote -t &lt;repository&gt; "*"</tt> or <tt>git ls-remote -t &lt;repository&gt; "$tagFilter"</tt>.<br/>
<a href="https://git-scm.com/docs/git-ls-remote.html">git-ls-remote</a> documentation.
</div>