Thanks for your answer. I should have mentioned that I tried that before posting, but couldn't get it to work. Here is my problem: before performing the DELETE, I do a GET, to double check what's going to be deleted.
First, it looks like I have to use ?locator=... in the URL, otherwise I always get a single build, not a list: https://teamcity/httpAuth/app/rest/builds/?locator=canceled:true,personal:true
But even then, I don't get all the expected builds. For instance, the following build is missing (accessed via https://teamcity/httpAuth/app/rest/builds/id:46306)
Such request https://teamcity/httpAuth/app/rest/builds/?locator=canceled:true,personal:true returns builds which are canceled AND personal, and build that you posted is not personal. So firstly you need to delete all canceled builds and then canceled+personal. Such requests should also return all not started builds.
You are right, sorry for the confusion caused by my post, however I still have problems getting this to work.
First, some builds were still missing in my results (hence my confusion earlier). After some experimentation, I found out that there are some default filters, as per documentation: Note: If build configuration utilizes feature branches then, by default, only builds from default branch are returned. To retrieve all builds, add the following locator: branch:default:any. The whole path will look like this: /httpAuth/app/rest/builds/?locator=buildType:One_Git,branch:default:any
So this is my request now: httpAuth/app/rest/builds/?locator=canceled:true,personal:true,count:1000,branch:default:any
The documentation is not entirely accurate from a user perspective, because I don't use feature branches, but rather remote run triggers with Gerrit.
Anyway, based on this, I tried: DELETE httpAuth/app/rest/builds/personal:any,branch:default:any,canceled:true
and got this back:
Status Code: 204 No Content
Cache-Control: no-cache, no-store
Connection: Keep-Alive
Content-Length: 0
Date: Thu, 26 Jun 2014 08:45:33 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Keep-Alive: timeout=5, max=100
Pragma: no-cache
Server: Apache-Coyote/1.1
I tried also: DELETE httpAuth/app/rest/builds/?locator=personal:any,branch:default:any,canceled:true
OK, that's quite counter intuitive, but it actually deletes a build, thanks.
So I am currently running this in a loop:
read -s CRED for i in `seq 1 10100` ; do echo $i curl -u $CRED --insecure --request DELETE "https://teamcity/httpAuth/app/rest/builds/personal:any,branch:default:any,canceled:true" done
Since it takes about 1 sec per build, and I have about 10000 builds to delete, it will take a few hours.
Is that currently the best way to do this ? If yes, I will open a feature request. This should be feasible in the web interface, or at least with a single REST command.
Hi,
You can perform it using REST API. You need to delete all canceled builds and then all canceled+personal:
DELETE http://teamcity:8111/httpAuth/app/rest/builds/canceled:true
DELETE http://teamcity:8111/httpAuth/app/rest/builds/canceled:true,personal:true
We also have a feature request - http://youtrack.jetbrains.com/issue/TW-8717, please watch and vote.
Hello Alina,
Thanks for your answer. I should have mentioned that I tried that before posting, but couldn't get it to work. Here is my problem: before performing the DELETE, I do a GET, to double check what's going to be deleted.
First, it looks like I have to use ?locator=... in the URL, otherwise I always get a single build, not a list:
https://teamcity/httpAuth/app/rest/builds/?locator=canceled:true,personal:true
But even then, I don't get all the expected builds. For instance, the following build is missing (accessed via https://teamcity/httpAuth/app/rest/builds/id:46306)
(sorry about the format. What's the proper way to insert XML code in a post ?)
Is it because it was never started ?
I actually want to delete all these builds that were canceled before they even started.
Olivier
Hi Olivier,
Such request https://teamcity/httpAuth/app/rest/builds/?locator=canceled:true,personal:true returns builds which are canceled AND personal, and build that you posted is not personal. So firstly you need to delete all canceled builds and then canceled+personal. Such requests should also return all not started builds.
You are right, sorry for the confusion caused by my post, however I still have problems getting this to work.
First, some builds were still missing in my results (hence my confusion earlier). After some experimentation, I found out that there are some default filters, as per documentation:
Note: If build configuration utilizes feature branches then, by default, only builds from default branch are returned. To retrieve all builds, add the following locator: branch:default:any. The whole path will look like this: /httpAuth/app/rest/builds/?locator=buildType:One_Git,branch:default:any
So this is my request now:
httpAuth/app/rest/builds/?locator=canceled:true,personal:true,count:1000,branch:default:any
The documentation is not entirely accurate from a user perspective, because I don't use feature branches, but rather remote run triggers with Gerrit.
Anyway, based on this, I tried:
DELETE httpAuth/app/rest/builds/personal:any,branch:default:any,canceled:true
and got this back:
I tried also:
DELETE httpAuth/app/rest/builds/?locator=personal:any,branch:default:any,canceled:true
But that doesn't work either:
Any idea what I am doing wrong ?
Olivier
The first DELETE request (without locator) which you send works correctly. It sends such response "204 No Content" after deleting a build.
OK, that's quite counter intuitive, but it actually deletes a build, thanks.
So I am currently running this in a loop:
read -s CRED
for i in `seq 1 10100` ; do
echo $i
curl -u $CRED --insecure --request DELETE "https://teamcity/httpAuth/app/rest/builds/personal:any,branch:default:any,canceled:true"
done
Since it takes about 1 sec per build, and I have about 10000 builds to delete, it will take a few hours.
Is that currently the best way to do this ?
If yes, I will open a feature request. This should be feasible in the web interface, or at least with a single REST command.
Now it's the only way to perform it. We have a feature request http://youtrack.jetbrains.com/issue/TW-8717, please watch and vote.
OK, thanks. I have voted for the mentioned issue, but also created another one to improve the REST API : http://youtrack.jetbrains.com/issue/TW-37080