mohamicorp / stash-jenkins-postreceive-webhook

Webhook used to notify Jenkins when commits are made to Stash
Other
138 stars 98 forks source link

Does this work for pull requests? #23

Closed abraithwaite closed 10 years ago

abraithwaite commented 11 years ago

I saw the blog post about requiring build passes in order to merge a pull request, but I couldn't find any pull request hook plugins.

Does this run every time a new pull request is made?

If so, does it run again after the pull request is merged?

warmfusion commented 11 years ago

I do not believe that Stash, nor the plugin, notify jenkins on a pull request.

If you want to use the build success restrictions in Stash, you'll need to setup Jenkins to build all branches - set "**" in the branch filter for the git configuration.

This will then trigger builds for all branches, each pinging back to Stash on completion, where a pull request will then (i assume) observe the most recent build status for commits in its branch, and then enforce the restrictions you declare.

kuhnroyal commented 11 years ago

I have to correct, the plugin does indeed notify upon pull request merges.

Pushes to branches which may be a part of an open pull request are picked up if your jenkins branch configuration is set up correctly. So just configure it like warmfusion said and you will be good to go.

warmfusion commented 11 years ago

Sorry, I believe that the notification sequence is as follows

If you'd like to avoid running builds for all branches, you could try setting up a parameterised build to trigger builds of specific branches manually. This would significantly reduce Jenkins utilisation, but still validate branches before merging.

kuhnroyal commented 11 years ago

When you commit into a branch that is build by Jenkins and configured to send success/failure notifications, Stash saves that information and since this build success notification in Stash is branch/SHA based, a new pull request on an already successful branch is successful in itself. Once you merge, a new notification is triggered by the plugin.

And btw the plugin does not trigger branch specific notifications, it is just a hint for Jenkins to check for new changes in the repository. Depending on the Jenkins git-branch configuration it will pick up the changes or not.

mikesir87 commented 11 years ago

Just as a note, the currently deployed version of the plugin in the Atlassian Marketplace does NOT have the pull request merge listener in it yet. The version of the plugin on the develop branch does.

I am doing some cleanup and trying to tweak one or two small things and will be hoping to deploy an update to the plugin by the end of this week. Once deployed, the plugin will notify Jenkins upon pull request merges.

However, the plugin will NOT notify upon pull requests being created. The ability to notify Jenkins is easy, but having Jenkins build the pull request isn't quite as straight forward and would require changes to the Git plugin to provide this functionality. There is a similar Jenkins plugin to do so with GitHub (https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin), but it is specific to GitHub and has a decent amount of configuration setup that's required.

As @kuhnroyal mentioned, as long as your branch succeeds (and is current with the branch you're trying to merge into), the build status of the last commit is sufficient to tell you if the pull request passes or not.

kuhnroyal commented 11 years ago

Oh yea, forgot about that, since I use the snapshot version. We should work on a new release!

mikesir87 commented 11 years ago

@kuhnroyal I just pushed quite a few updates to the develop branch and updated the version to 2.0-SNAPSHOT. Can you try it out and see how it works for you? If it looks good, I'll go ahead and prepare it for release.

kuhnroyal commented 11 years ago

I will give it a try on monday. Am 12.07.2013 18:58 schrieb "mikesir87" notifications@github.com:

@kuhnroyal https://github.com/kuhnroyal I just pushed quite a few updates to the develop branch and updated the version to 2.0-SNAPSHOT. Can you try it out and see how it works for you? If it looks good, I'll go ahead and prepare it for release.

— Reply to this email directly or view it on GitHubhttps://github.com/Nerdwin15/stash-jenkins-postreceive-webhook/issues/23#issuecomment-20889462 .

kuhnroyal commented 11 years ago

Can not get it to work in 2.5 or 2.5.2. Server seems fine, UI doesn't load due to script errors.

mikesir87 commented 11 years ago

Just by chance, do you have the README Parser plugin installed? I've heard from several others that the UI doesn't load when that plugin is enabled. Haven't looked completely into what the conflict is yet though.

mikesir87 commented 11 years ago

FYI... just pushed a refactor due to the "new" (introduced in 2.3.0) event RepositoryRefsChangedEvent, which both push events and pull request merge events implement. Makes code a little more straight forward now. Shouldn't impact end-user at all. Tested all arcs on my end on 2.5.0 and seems to be doing fine.

kuhnroyal commented 11 years ago

The README Parser plugin did the trick. However it still doesn't work since I use a custom Stash port and with the new setup I can not configure it.

mikesir87 commented 11 years ago

Are the repo clone URLs correct on the UI, or do you have to modify those too? The plugin should be using the same method that is used to generate those clone urls.

kuhnroyal commented 11 years ago

In our setup these only work from external, internal you have to add a custom port. This is done to skip HTTPS client authentication in the local network.

mikesir87 commented 11 years ago

Ok. Good to know. May re-think the setup a little bit. Hadn't thought of that use case. I've got an idea and will try to send you an update here shortly.

mikesir87 commented 11 years ago

@kuhnroyal Just pushed up another attempt at the setup. Let me know what you think.

kuhnroyal commented 11 years ago

@mikesir87 it didn't work because my project key in the url was upper case in Jenkins (..scm/FOO/bar.git) and lower case in the stahs plugin. Jenkins could not match this. And now I am back to what I noticed a couple weeks back - no matter if the url ist set to ssh or https or if I add the port or not, Jenkins always gets trigger successfully. I can set the url to (dgsdg://stash.example.com:12345/scm/foo/bar.git) and it works, Jenkins strips off the protocol and port when matching the url. I have Jenkins Git plugin 1.4.0 installed.

kuhnroyal commented 11 years ago

Just an idea, we could trigger both urls with uppercase and with lowercase project key.

mikesir87 commented 11 years ago

In the config screen, you can make changes to the URL it uses, so if you need to make it upper case, you can do so. I'll see what the easiest way to do both upper and lowercase project keys and get that added in.

kuhnroyal commented 11 years ago

GUI not loading after Stash 2.6 upgrade, Readme Parser Plugin is disabled, will check the logs tomorrow.

mikesir87 commented 11 years ago

Just confirmed that I see the same thing. The production version still works just fine. Nothing in the logs either... just 404s when making the requests. Still looking around...

mikesir87 commented 11 years ago

@kuhnroyal With Jenkins stripping the protocol and port, does it seem to strip the username too? If so, we can just trigger both the ssh and http repo URLs. I'm seeing that username has to match. Do you see the same?

mikesir87 commented 10 years ago

Just released version 2.0 to the public. Going ahead and closing this now.

nightwolfzor commented 9 years ago

As an alternative which still works with this plugin is a Stash pull request builder plugin which lets you do pre merge builds. Much like the GitHub pull request builder; https://github.com/nemccarthy/stash-pullrequest-builder-plugin