ArcBees / teamcity-plugins

40 stars 26 forks source link

Add support for Mercurial #6

Open MaksSlesarenko opened 10 years ago

meriouma commented 10 years ago

Are you using the latest version? Also, be sure to add +:refs/heads/* in Branch specification of your VCS root. This bug was found and fixed in the last version, but it requires the branch specification to be able to find the commits.

Thank you!

MaksSlesarenko commented 10 years ago

It triggers on pull-request but says no changes.

TeamCity 8.0.5 plugin from build #13 http://teamcity.arcbees.com/repository/download/TeamCityPlugins_CompileMaster/710:id/bitbucket/target/bitbucket.zip

meriouma commented 10 years ago

Did you install a previous version of the plugin, then updated to the new one?

meriouma commented 10 years ago

If it's not the first build on the branch, it might show that there's no change (since the last build)

MaksSlesarenko commented 10 years ago

The plugin was not updated. I see in build agent work directory that the code was checkouted from main branch without changes from PR.

meriouma commented 10 years ago

The thing is that we had that bug in the past, and fixed it with the latest version.

What is the version number shown for the plugin on the page : {yourTeamCityServer}/admin/admin.html?item=plugins

MaksSlesarenko commented 10 years ago

http://awesomescreenshot.com/06c21v18e7

meriouma commented 10 years ago

I'm out of ideas here. The plugin works on our TeamCity server and I've had another person that reported the bug you are experiencing, but the last version fixed it and it works fine for him too. Do you have anything relevant in your log files?

MaksSlesarenko commented 10 years ago

Can you give any tips what to look for?

seif commented 10 years ago

I ran into such an issue when my branch spec didn't match what the plugin was passing.

Try manually triggering a build, selecting a branch to run build from and then look at what teamcity has in the build history for the branch name. That match what the bitbucket plugin is passing (I think you can see what that is by looking at one of the builds triggered by it)

MaksSlesarenko commented 10 years ago

Does this plugin support mercurial? As I understand +:refs/heads/* doesn't make much sense for hg.

meriouma commented 10 years ago

Ah that's a good point, the plugin was only tested with git. I'm not sure what's the branch specification for mercurial.. Maybe you can try +:* ?

MaksSlesarenko commented 10 years ago

As I understand branch is not created on pull request in mercurial. You need to checkout upstream branch and than do

hg import https://bitbucket.org/!api/2.0/repositories/COMPANY/PROJECT/pullrequests/REQUEST_ID/diff
meriouma commented 10 years ago

In bitbucket, a branch is not created for git pull requests either. The plugin uses the bitbucket REST API to find the pull requests, not the VCS. What the branch specification does is gather information on branches so the plugin can find the commits.

meriouma commented 10 years ago

I think +:* should do it (http://stackoverflow.com/questions/13341271/teamcity-ignores-changes-in-different-branches-of-mercurial#comment18355005_13341959)

MaksSlesarenko commented 10 years ago

I've already tried +:* with no luck. As I understand from what you said above, wrong branch specification can result than commits are not displayed at TeamCity's build page. But my source code does not have changes from PR, that means that hg import was not executed.

meriouma commented 10 years ago

Can you try +:* and wait for the next PR to open?

MaksSlesarenko commented 10 years ago

I have set branch to default branch specification to +:*

if I create a pull request within my repository from develop to default than develop branch gets a build if I create a pull request from fork default to main default than default is built, no patches applied if I create a pull request from fork develop to main default than develop is built, no patches applied

MaksSlesarenko commented 10 years ago

I agent's build log there is comments that patch was applied http://pastebin.com/qHQsS5Vc

MaksSlesarenko commented 10 years ago

teamcity-activities.log http://pastebin.com/ZUqr3qN8

meriouma commented 10 years ago

Thank you for those tests. So if I understand, your first PR from a branch to another triggered the build with the correct changes? But the PR from a fork didnt?

MaksSlesarenko commented 10 years ago

In first case default should have been built + patch from develop, instead develop itself was built.

Also in build logs I have such thing

teamcity.build.branch=develop
vcsroot.branchName=default

From what I see now branch specification +:* just overrides specified branch name

meriouma commented 10 years ago

The first case is the expected result, as develop contains default + your changes. For forks, I must say that I don't think it's supported. There's no way teamcity knows about the forks, because the VCS root doesn't include them

MaksSlesarenko commented 10 years ago

The first case is the expected result, as develop contains default + your changes

But TeamCity labled it as a develop branch build

For forks, I must say that I don't think it's supported. There's no way teamcity knows about the forks, because the VCS root doesn't include them

Actually it knows, otherwise build would not be triggered on pull request from fork.

In any case, can your plugin export parameter with PULL_REQUEST_ID to Ant or do you know a way I can get it in Ant from TeamCity? This will do the job for me.

meriouma commented 10 years ago

The reason it's labeled develop is that you want develop to be compiled when you ask for a PR from develop to default, as develop is the branch containing the new changes and is the branch you want to test to be sure it doesn't break anything, not default. I might be missing something about your use case though.

As for the parameter, I can look on what's possible with TeamCity to pass to the build

MaksSlesarenko commented 10 years ago

As I understand your in your plugin gets changeset number from api and calls setChangeset(CHANGESET_ID) and then git implicitly changes branch to pull request, because pull requests are stored within same repository in git. But this approach does not work for mercurial. Maybe you can use https://bitbucket.org/aragost/javahg/ to import patch that is provided by bitbucket api to project working copy in build agent?

olafleur commented 10 years ago

Is this issue still relevant?

meriouma commented 10 years ago

Yes it is

scottaubrey commented 9 years ago

Any idea on when you might work on this? I'm keen to get a pull-request setup on mercurial/bitbucket combo, and there are so little tools supporting this. I had thought my salvation was here, but alas, it doesn't work.

I'm not a Java developer, so I did clone the repo, but very quickly got lost in how to map the links that come back from bitbucket using gson.

Could even exporting the pull request ID into the TeamCity Env variables be the place to start? Then the first build step can download the patch (PullRequest.links.patch) and apply it?

meriouma commented 9 years ago

Sorry for the delays. We are not using mercurial at the moment so it's hard to tell when we'll implement this feature. If anyone wants to contribute this, pull requests are more than welcome!