Thursday, September 10, 2015

Getting TeamCity build status' in Stash

Here is a quick hack to get build statuses from TeamCity appearing in Stash.

In Chrome, add the "Control Freak" plugins (which lets you attach your own javascript and css to existing sites).

Visit the build for a feature branch in TeamCity and note the url:
For me this is http://your_teamcity_server:9090/viewType.html?buildTypeId=Spectra_SpectraCi&branch_Spectra_SpectraDev=lahm-424-sample-tracking-error-handling&tab=buildTypeStatusDiv
Note the 'Teamcity server address', 'buildTypeid' and 'branch_xxx' parts of the url.
Now visit your "Pull Requests" page in Stash.
Open the ControlFreak dialog.
Click "This domain"
In the Libs tab and select "JQuery"  (I picked 2.1.0 (Google CDN)
In the Javascript Tab enter the following code:

$(".source .name").each(function(){ var self = $(this); self.closest("td.source").append($("<a href='http://your_teamcity_server:9090/viewType.html?buildTypeId=Spectra_SpectraCi&tab=buildTypeStatusDiv&branch_Spectra_SpectraDev="+self.text()+"&guest=1'><img src='http://your_teamcity_server:9090/app/rest/builds/buildType:(id:Spectra_SpectraCi),branch:"+ self.text() +"/statusIcon'/></a>"))});

Change the above to reflect your
* TeamCity server address and port,
* TeamCity buildid and branch_xxx name.

Note: This works for me because we are using feature branches in Git and TC is building them. Your config may vary.
Post a Comment

GitHub Projects