tomasbjerre / pull-request-notifier-for-bitbucket

Bitbucket Server plugin that invokes a custom URL when a pull request event is triggered.
Other
184 stars 74 forks source link

Configuring against forked development #157

Closed mattadamson closed 8 years ago

mattadamson commented 8 years ago

Team,

Has anyone got this working successfully when using the forked workflow in Stash? In this configuration all developers will have a separate repository url which they create there branches and merge back to the central repository.

If so how do you configure the jenkins job without having a separate job per developer fork? We have many developers so creating many jobs per developer isn't great for maintenance

https://christiangalsterer.wordpress.com/2015/04/23/continuous-integration-for-pull-requests-with-jenkins-and-stash/

Thanks

tomasbjerre commented 8 years ago

I do that with a shell script build step in Jenkins.

git clone $PULL_REQUEST_TO_HTTP_CLONE_URL  
cd *  
git reset --hard $PULL_REQUEST_TO_HASH  
git status  
git remote add from $PULL_REQUEST_FROM_HTTP_CLONE_URL  
git fetch from  
git merge $PULL_REQUEST_FROM_HASH  
git --no-pager log --max-count=10 --graph --abbrev-commit

#compile command here ...

What is the problem that you have?

mattadamson commented 8 years ago

thanks @tomasbjerre

I'm starting to set this up however I was thinking from

https://christiangalsterer.wordpress.com/2015/04/23/continuous-integration-for-pull-requests-with-jenkins-and-stash/

where it mentions this is used

https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Pushnotificationfromrepository

which states

"This will scan all the jobs that: Have Build Triggers > Poll SCM enabled. No polling Schedule is required. Are configured to build the repository at the specified URL Are configured to build the optionally specified branches or commit ID"

How could this work with forks for a single jenkins job because the job can only have one GIT URL whereas each developers fork has a different URL.

Thanks

tomasbjerre commented 8 years ago

I dont use the git-plugin. I dont use the option to checkout source from scm at all. I just use a simple shell script build step.

mattadamson commented 8 years ago

Ah I see so how does the pull request notifier plug in when calling Jenkins know to use your specific job where you configured the shell script build step?

tomasbjerre commented 8 years ago

There is a field for specifying the URL. See http://bjurr.com/continuous-integration-with-bitbucket-server-and-jenkins/

mattadamson commented 8 years ago

@tomasbjerre that's the URL for the actual jenkins server though. I meant when the URL comes to Jenkins how does it know to use your specific jenkins job configured with the shell script you mention? e.g. consider it's called GenericStashBranchBuilder. How is that job invoked from the generic URL coming to jenkins?

tomasbjerre commented 8 years ago

The url mentioned in the blog under the headline "Pull Request Notifier for Bitbucket Server" is points to that job.

Den 15 nov. 2016 9:42 PM skrev "mattadamson" notifications@github.com:

@tomasbjerre https://github.com/tomasbjerre that's the URL for the actual jenkins server though. I meant when the URL comes to Jenkins how does it know to use your specific jenkins job configured with the shell script you mention? e.g. consider it's called GenericStashBranchBuilder. How is that job invoked from the generic URL coming to jenkins?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/157#issuecomment-260761579, or mute the thread https://github.com/notifications/unsubscribe-auth/AAa1E9mzXMAocvK2GtJo9w1yXwzdJCngks5q-hlIgaJpZM4KxokJ .

mattadamson commented 8 years ago

thanks @tomasbjerre , we can close this issue now.

mattadamson commented 7 years ago

Hi @tomasbjerre actually on testing this script it doesn't seem to change the workspace to reflect the contents of the fork rather than the central branch $PULL_REQUEST_TO_HTTP_CLONE_URL. Can you think why this could be as the jenkins workspace also doesn't reflect this.

I noticed the script doesn't have any git commands to change the branch too e.g. if the source of the PR is a forked with branch xxx shouldn't we also handle this in the generic script?

Many thanks

mattadamson commented 7 years ago

If you want me to open another ticket for this just let me know. I know it's not ideal reopening tickets but it's also closely related to this

It appears the following lines could also be the root cause from the log

merge: e92792992f1b437ee1e01e2c15f5d55f6c078c83 - not something we can merge fatal: could not read Password for 'https://admin@stash.com': No such device or address

i.e. from the script

git remote add from $PULL_REQUEST_FROM_HTTP_CLONE_URL
git fetch from

The git fetch call doesn't appear to work

tomasbjerre commented 7 years ago

You dont need the branches. The script uses the commit hashes of the branches.

It looks like the jenkins user does not have read access to the forks.

Den 20 nov. 2016 23:57 skrev "mattadamson" notifications@github.com:

If you want me to open another ticket for this just let me know. I know it's not ideal reopening tickets but it's also closely related to this

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/157#issuecomment-261812891, or mute the thread https://github.com/notifications/unsubscribe-auth/AAa1E0KKrh1kDw3CW9v7YTKVSF7318ojks5rANBSgaJpZM4KxokJ .