Problem with commit-status-publisher compilation Follow
I'm having TeamCity connected to Bitbucket Server and for some reason some of build statuses haven't been visible. After some investigation with wireshark and postman I've found out that commit-status-publisher pushes to bitbucket information about branch (https://docs.atlassian.com/bitbucket-server/rest/7.4.0/bitbucket-rest.html#idp219). In our project we use full gitflow with forks so pull requests to upstream are made from forks. So in our case commit-status-publisher pushes to bitbucket information about build status with wrong ref:
"ref": "refs/pull-requests/<PR number>/from"
In this case it really is the branch that was builded but Bitbucket itself don't show status of this build based on this branch but based on original branch (from someone's fork). If you just remove this one line from message body and push commit status again it works as intended.
Second thing I've noticed is that as build key in bitbucket api you always use build configuration key form teamcity which means that if you've builded 1 pull request 3 times after each change, in bitbucket you see only one (latest) build status because you are overwriting same build status over and over.
So I thought that waiting for someone to replicate my problem and fixing it will take much longer than solving it by myself. In the end it turns out I was wrong. I've found code responsible for this issue. Fixed that (2 line fix) and wanted to compile it...
And here comes the nightmare part. Since I'm .Net dev I have no knowledge about java environment and IDE. I've followed instructions in:
And to be honest each of them gives me different errors and non of them works as intended. Is there any up to date documentation that can be followed to compile this plugin?
Please sign in to leave a comment.
It seems similar issue has been reported by other users recently. More specifically if TeamCity reports a build status to BitbucketServer 7.4+ it uses the new API and includes the branch of the build in it. What we observe is described in the following ticket on Atlassian's site:
We also have created an issue in our issue tracker now: https://youtrack.jetbrains.com/issue/TW-72283
Not reporting the ref field with the status sounds like a simple solution, we did not try it yet. Thank you for the suggestion! I will be back to you on that. If this doesn't cause any other problems we will publish the updated version of the plugin in that issue. BTW, which version of TeamCity do you use?
I'm using 2021.1.1 version of TeamCity connected to Bitbucket Server in version 7.14.0.
Could you also change bitbucket status key to be teamcity build configuration ID + build number instead of teamcity build configuration ID alone. Like I've written in previous post. If you build 1 branch/pull request many times but you always use same key you are overwriting historical data of previous build statuses in bitbucket.
Do you mean Bitbucket Server 7.41? As for versions below 7.40 TeamCity should not use the new status API endpoint.
As for adding the build number to the key, we cannot make this a default behaviour. The thing is that a number of build configurations may run builds on the same commit and publish statuses to it. For many TeamCity users a green status of a commit means that all statuses currently associated with the commit are green. If we use the build number in the key this will cause troubles for many TeamCity users, as in their case if a previous build of the same build configuration failed (not due to this particular commit, but due to dependencies or some other factors), but the most recent build in the same build configuration succeeded, the overall status will still indicate a failure and will not reflect the current state of things.
We could possibly support cusomisation for the key (and may be other fields). There is an open feature request relevant to this: https://youtrack.jetbrains.com/issue/TW-62101
No, I mean Bitbucket Server 7.14.0 and new api was added in 7.4.0 not 7.40 so older version. Version 7.14 is most recent (https://confluence.atlassian.com/bitbucketserver/release-notes-872139866.html)
Pawel, my apologies, you are right. I got lost in versions a bit :)
Since it looks like it will take some time, I will ask my question again. Is there any proper documentation showing how can I compile this plugin so I can create my ow version for now?
While the readme file is not up to date there (our apologies for that), please use the following command line to build the plugin locally:
./gradlew clean build test -PTeamCityVersion=2021.1.1 -PPluginVersion=SNAPSHOT -PTeamCityTestLibs=TEAMCITY_DISTR/devPackage/tests -PTeamCityLibs=TEAMCITY_DISTR/webapps/ROOT/WEB-INF/lib
where TEAMCITY_DISTR is an absolute path of a TeamCity distribution directory.