How do I trigger a build for a specific git commit via Teamcity REST API?

Hello!

I know how to trigger a build for the latest change in the cvs.
But how do i specify which commit I want to build?
Or, which branch I want to build?

<build>
    <buildType id="Marc_Build"/>
<properties>
        <property name="deploy_name" value="somecustomparam"/>
<changes>
<change version="s5hab2ahsjh2..."
</changes>
    </properties>
</build>

3 comments
Comment actions Permalink

Hi Anders,

You can trigger a build for a specific change, by adding:

<lastChanges>

    <change id="modificationId"/>

</lastChanges>
where "change id" is the id can be seen in the change node listed by the REST API or in the URL of the change detail UI page (http://host:8111/viewModification.html?modId=760&personal=false&buildTypeId=<buildType>&tab=vcsModificationFiles).
Also you can get change id by revision:
http://localhost:8111/httpAuth/app/rest/changes/version:60b45e9501e24387d50a955d81261e18b047cfd5

To specify branch use

branchName="" parameter:
<build branchName="logicBuildBranch">

    <buildType id="buildConfID"/>

</build>
0
Comment actions Permalink
http://localhost:8111/httpAuth/app/rest/changes/version:60b45e9501e24387d50a955d81261e18b047cfd5


This lets me check the changes for the commit, but is there a rest endpoint to kick off a build for that sha?

For example, you can do something like

    http://#{hostname}/httpAuth/action.html?add2Queue={buildname}

but is there something along the lines of

    http://#{hostname}/httpAuth/action.html?project={projectname}&commit_sha=60b45e9501e24387d50a955d81261e18b047cfd5?

0
Comment actions Permalink

Hi Jesse,

It is not possible to trigger build for commit, while you can trigger build on specific change:

curl -v -u user:password http://teamcity:8111/app/rest/buildQueue --request POST --header "Content-Type:application/xml" --data-binary @build.xml

where build.xml is:

<build>

  <buildType id="buildConfID"/>

  <lastChanges>

    <change id="modificationId"/>

  </lastChanges>

</build>

0

Please sign in to leave a comment.