Reputation: 31
I am trying to trigger TeamCity build from command line. Firstly, I tried:
curl http://<user name>:<user password>@<server address>/httpAuth/action.html?add2Queue=<build configuration Id>
But in latest versions of TeamCity this approach is removed and response is following:
405 Only POST method is allowed for this request.
So, based on information from https://www.jetbrains.com/help/teamcity/rest-api.html#RESTAPI-BuildRequests it should work via REST API in this way:
url -v -u user:password http://teamcity.server.url:8111/app/rest/buildQueue --request POST --header "Content-Type:application/xml" --data-binary @build.xml
build.xml example:
build.xml
<build>
<buildType id="buildConfID"/>
</build>
For me is not clear where should I place my configured build.xml?
Upvotes: 3
Views: 4153
Reputation: 1915
curl -u user:password -X POST \
https://teamcity.host.io/app/rest/buildQueue \
-H 'Accept: application/json' \
-H 'Content-Type: application/xml' \
-H 'Host: teamcity.host.io' \
-d '<build branchName="refs/heads/master">
<triggeringOptions cleanSources="true" rebuildAllDependencies="false" queueAtTop="false"/>
<buildType id="Test_Configuration_ID_for_trigger"/>
<lastChanges>
<change locator="version:e2418b4d7ae55ac4610dbff51bffe60d1f32e019"/>
</lastChanges>
<properties>
<property name="env.startedBy" value="build was triggering from %teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%"/>
</properties>
</build>'
you can skip lastChanges
for run the build on the Latest changes
Upvotes: 0