TeamCity 2017 Rest Hook for own BitBucket instance

Hello,

we have our own BitBucket server and we used till now the Http Request Post Receive Hook plugin in BB.

But it only has the option for URL encoded parameters or JSON.

 

Does anyone know which plugin can be used for the new Version of Teamcity?

 

 

Greetings,

Erwin

0
6 comments

Hi Erwin,

If I understood you properly, you mean creating a post-commit hook so that it triggers some action TeamCity, right? Instructions are here: https://confluence.jetbrains.com/display/TCD10/Configuring+VCS+Post-Commit+Hooks+for+TeamCity. URL encoded parameters are just fine.

0
Avatar
Permanently deleted user

Hi,

 

I had rather in mind something like sending a POST

 

https://<SERVER_URL>:<PORT>/httpAuth/app/rest/buildQueue

With XML

<build personal="true" branchName="<A_VARIABLE">
</build>
 
The variable schould point to the GIT branch which was pushed to.
 
Which could be trigger in the Versions before via:
https://<SERVER_URL>:<PORT>/httpAuth/action.html?add2Queue=<QUEUE_ID>&branchName=${refChange.refId}
 
where refChange.refId is the variable for the GIT branch which was pushed to.
0

Hi Erwin,

It's fine to make a JSON request, it's accepted by our REST API as well, so it should work, just convert the XML objects to JSON "{ build: { personal: true, branchName: <name> } }" (roughly, you'd need to add the quote marks, etc). Examples on how to use this here: https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-TriggeringaBuild

Commit hooks are slightly different in that they perform a different series of actions, as they might not need to trigger a build, or they might need to trigger several. If you would like to trigger 3 builds, you would need to make 3 REST API triggers, while calling the commit hook will just check for changes, then act as if it had checked the VCS Root automatically, triggering as many builds as triggers are set up for it. But if you only need one trigger, feel free to request the trigger directly.

0
Avatar
Permanently deleted user

Thanks for your reply. After you confirmed that it works with JSON I got it going. Seems the first time I tried I did somethign wrong :)

One question though. I am using the plugin https://bitbucket.org/a-v-r/bitbucket-http-request-hook/wiki/Home.

When I configure the Hook and use as branchName the variable ${refChange.refId} which is translated to "refs/heads/myFeature" then TeamCity does not find the appropriate changes.

What do I need to provide as branchName, really?

0

Hi Erwin,

glad you got the JSON working. That branch name looks about right. Could you debug whether the json was getting sent properly? When some parameter isn't passed properly, the build will fall back to the default branch.

0
Avatar
Permanently deleted user

Hi thanks. Yes I got it working. The trigger in the job itself had some side effects. After removing the triggers (which I played around with :) ) it built it and also for every branch configured.

 

Thanks.

0

Please sign in to leave a comment.