0
votes

Following a TC upgrade to 2018 My previous script of triggering a TC build with parameters is not working

The script we were using uses the following api:

https://[server]/httpAuth/action.html?add2Queue=[build name]&name=[param name]&value=[param value]

I'm trying to migrate to restApi from (https://confluence.jetbrains.com/display/TCD18/REST+API#RESTAPI-QueuedBuilds):

I have tried

https://[server]/app/rest/buildQueue?locator=buildType:[build name],[param name]:[param value]

Currently I have 2 issues:

  1. I get a build triggered successfully - but it has not been triggered
  2. Documentation was not clear, how to I trigger the build with parameters ? Can you please advise on how to trigger the build successfully with parameters (also could be more than 1)
1
As it turns out the upon upgrading to TC 2018, our script started failing on the above with a GET call. Changing it to a POST call resolved the issue. No need to migrate to the new TC REST API as it is still backwards compatible.CapBird

1 Answers

1
votes

Firstly you right TeamCity documentation is not clear. Respect to this link;

For triggering a build you must make POST request to this url and send buildType id through body.

http://localhost:8111/httpAuth/app/rest/buildQueue 

Also you can pass configuration parameter into body.

XML body for trigger build with parameters:

<build><buildType id="YourBuildTypeId"/>
<properties><property name="PARAM1" value="VALUE1"/></properties>
</build>

JSON body for trigger build with parameters:

{
  "buildType": {
  "id": "YourBuildTypeId"
},
  "properties": {
  "property": [
    {
     "name": "PARAM1",
     "value": "VALUE1"
    },
    {
     "name": "PARAM2",
     "value": "VALUE2"
    }
   ]
  }
}

You can use below curl script.

curl -X POST \
http://localhost:8111/httpAuth/app/rest/buildQueue \
-H 'Accept: application/json' \
-H 'Content-Type: application/xml' \
-d '<build><buildType id="YourBuildTypeId"/>
<properties><property name="PARAM1" value="VALUE1"/></properties>
</build>'