Find the latest SVN tag
I am setting up a Continuous Integration job that patches an external library and releases the patched version locally.
However, the external library uses TRUNK for development, and I would like my CI job to automatically select the latest release tag for checkout.开发者_如何学运维
Does SVN have that functionality?
(bash Shell Scripts are ok)
Hm...What about the following:
svn log URL/tags --limit 1
will print out the last tag.
This will work if nothing better can be found:
svn log -v <tagsurl> | awk '/^ A/ { print $2 }' | grep -v RC | head -1
(the grep -v RC part strips release candidates)
Source: this answer to a previous question
Here it is a more generic solution. Sometimes we don't only need the latest tag, but the latest tag which respect a pattern :
last_tag=$(svn ls http://svn_rep/XXX/tags/ | egrep '^MySpecialProject_V([0-9].)+[0-9]+[a-zA-Z_0-9]*' | sort --reverse | head -1 2>&1)
Here we will have the latest tag of the project whose name starts by MySpecialProject_V. And if we had these tags :
Koko_V3.1.0.0
MySpecialProject_V1.1.0.0
MySpecialProject_V1.2.0.0
MySpecialProject_V2.1.0.0
MySpecialProject_V2.2.0.0
The result of :
echo $last_tag
...would be :
MySpecialProject_V2.2.0.0
I hope this would help someone.
For windows, you could use powershell:
$path = (([Xml] (svn log --xml $Url --verbose --username $Username --password $Password)).Log.LogEntry.Paths.Path |
? { $_.action -eq 'A' -and $_.kind -eq 'dir' -and $_.InnerText -like '*tags*'} |
Select -Property @(
@{N='date'; E={$_.ParentNode.ParentNode.Date}},
@{N='path'; E={$_.InnerText}} )|
Sort Date -Descending |
Select -First 1).path
Where $Url is the url of you tags
Svn has no definition of tag. I assume you mean revision. The symbolic revision HEAD points to the latest revision of a tree.
e.g.
svn export -rHEAD ...
精彩评论