Reputation: 7269
I have some builds. Each build has two tags. Tags show module name and version. So tags loogs like one-module
and 1.2.3
or two-module
and 4.5.6
.
I can do this:
/httpAuth/app/rest/builds/?locator=tags:one-module,branch:unspecified:any&fields=build(tags(tag))
I will get this:
{
"build": [
{
"tags": {
"tag": [
{
"name": "1.2.4"
},
{
"name": "one-module"
}
]
}
},
{
"tags": {
"tag": [
{
"name": "1.2.3"
},
{
"name": "one-module"
}
]
}
}
]
}
Now I want to get latest build with tags one-module
and 1.2.4
. How I can do this?
I try this:
/httpAuth/app/rest/builds/?locator=tags:one-module,1.2.4,branch:unspecified:any&fields=build(tags(tag))
But I got this:
Error has occurred during request processing (Bad Request).
Error: jetbrains.buildServer.server.rest.errors.LocatorProcessException: Bad locator syntax: Invalid dimension name :'1.2.4'. Should contain only alpha-numeric symbols or be known one. Details: locator: 'tags:one-module,1.2.4,branch:unspecified:any', at position 16
Invalid request. Check locator is specified correctly.
I have TeamCity version 9.1.6. TeamCity REST API BuildLocator documentation says:
tags: - ","(comma) - a delimited list of build tags (only builds containing all the specified tags are returned)
So, I try to select build by 2 or more tags like this. This doesn't work?
What I am doing wrong? How I can get build latest build by 2 or more tags?
Upvotes: 1
Views: 2300
Reputation: 31
Either of the above solutions will work for obtaining builds with multiple tags. This one is now legacy: tags:(one-tag,two-tag,three-tag,etc-tag)
.
Current docs recommend to do it this way: tag:one-tag,tag:two-tag
Unfortunately, you can't use more than one "not" tag clause (either in the legacy syntax or the current).
If you try to use more than one "not" tag clause in the legacy syntax, you just get a bad result--i.e. a build or builds that only exclude one of the excluded tags; if you use the current syntax, you get a 400 bad request with the following exception: "Only single 'not' dimension is supported in locator."
Upvotes: 0
Reputation: 568
Since Teamcity 10 you can also just list several tag clauses (or 'not' tag clauses), e.g.
http://server/guestAuth/app/rest/builds?locator=defaultFilter:false,tag:sel,not:tag:unres
Oddly, I've not found a way to select for builds with any of several tags.
Upvotes: 0
Reputation: 7269
I accidently find the way to get build by two or more tags.
Solution: use build locator this way: tags:(one-tag,two-tag,three-tag,etc-tag)
I am not sure it is correct solution. If it is correct JetBrains just forgot to update docs for TC REST API. Or it is just something internal for TeamCity. I asked about here in comments to the docs.
Upvotes: 3