Teamcity REST API get latest successful build on a branch
I can use this url to get the latest build on a branch:
but it fails if the branch name contains
/ (e.g., git flow names branches
I’ve tried url encoding the
/. For example, if
$branchName$> == 'release/branchName' I use
- works –
- fails –
I don’t get an API error, but the api result is empty.
2 Solutions collect form web for “Teamcity REST API get latest successful build on a branch”
You can work around this by putting your build locator into a query string rather than as part of the path element of the URL, i.e. instead of
/builds/branch:name:release%2F1.0.1 or the like, you could do
/builds?locator=branch:name:release%2F1.0.1. The format of the data coming back does not seem to be the same, but it does include the internal build ID, so you can always make a second request for that exact build using that ID, e.g.
Another point, which I have not personally tried, is found on this comment from JetBrains’ issue tracker:
I delved into this a bit and discovered that Tomcat versions 6.0.10 and newer by default don’t accept encoded slashes and backslashes in path elements anymore. This behavior can be changed by changing two Tomcat server properties (found on http://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10):
I do not know if this is considered a bad security practice.
Apparently this is a bug in TeamCity as of 8.0.3
It looks like it is being worked on.