Bamboo 6.0 brings the pull request support for Bitbucket Server, see the release notes:
https://confluence.atlassian.com/bamboo/bamboo-6-0-release-notes-894743804.html
Its a good news that Bamboo 6.0 supports the PR builds now.
Wonder there is a example guide to setup the plan with all configurations needed in Bamboo? For me its a nightmare setting up a CI build on PR for bamboo plans.
If you could show us all the settings/configurations required to setup exact steps that would be really appreciated.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There's presently no way of doing that without writing all the pieces yourself.
On Bamboo, you'll need the following configurations:
* Adding a shell script step to fetch the remote pull request references; they are considered internal use only, but that's the only way right now. More information in this question. I use the following:
git remote | grep -q origin || git remote add origin "https://${bamboo.user}:${bamboo.password}@${bamboo.repo.url}" git fetch origin '+refs/pull-requests/*/merge-clean:refs/remotes/origin/pr/*' git fetch origin '+refs/pull-requests/*/from:refs/remotes/origin/pr-from/*'
* Checkout the desired pull request; that means adding a plan variable that can be used on the build tasks. For example, a variable "prnumber" would be used like this:
git checkout pr/${bamboo.prnumber}
* Update build status on Stash using the REST API. This article has everything that's needed, but note that "merge-clean" is what is going to be merged (and, thus, what one needs to build), but the build status on the pull request status on Stash only shows up for the source commit -- that's why I bring the two references above.
* Since there's no variable in Bamboo to indicate whether a build has succeeded or not, I use three steps: mark a build in progress after checkout, mark a build as succeeded as the last task, and then, on a final task (which is always run, whether the previous tasks succeed or not), I mark the build as failed if I don't find a file left behind indicating the build has succeeded (I use a file I create to store the json I send to Stash).
On the Stash side, things are more difficult because you have to listen to pull request events -- the existing hooks don't cover it. This question covers most of what's needed. Because you are not using the hook mechanism, you won't have access to the easy per-repository configuration it provides, so you'll have to write it yourself.
One last note: you use the "queue" REST interface on Bamboo to trigger the build from Stash. Look at your Bamboo's version API documentation here to see the details (a generic REST description found elsewhere doesn't go into that).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I dont' know how I can add the script you uploaded... Can you help me?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Daniel Sobral Your answer is almost 2 years old. Do you know if the situation has changed since?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An easier solution would be to write a hook that creates a branch under `refs/heads` for every ref it finds under the PR ref.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any news on this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Andrea I found a JIRA issue on this.1 I've just upvoted it and I suggest you do the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Antoine Luciani thanks! done
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any update? Can it be done without writing all the pieces by hand?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This plug-in will help you with it: https://marketplace.atlassian.com/plugins/se.bjurr.prnfs.pull-request-notifier-for-stash/server/overview
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you provide more information on how that plugin helps? Do you use it to trigger a Bamboo manual build or something?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, we use it to start a build of a build-plan that is able to build for every repository and branch we have. So this plugin call the rest api: <bamboo server>/rest/api/latest/queue/PR-BLD With the plugin parameters: bamboo.PULL_REQUEST_ID=${PULL_REQUEST_ID}&bamboo.PULL_REQUEST_TO_SSH_CLONE_URL=${PULL_REQUEST_TO_SSH_CLONE_URL}&bamboo.PULL_REQUEST_TO_REPO_NAME=${PULL_REQUEST_TO_REPO_NAME}&bamboo.PULL_REQUEST_TO_BRANCH=${PULL_REQUEST_TO_BRANCH}&bamboo.PULL_REQUEST_TO_REPO_PROJECT_KEY=${PULL_REQUEST_TO_REPO_PROJECT_KEY}&bamboo.PULL_REQUEST_URL=${PULL_REQUEST_URL}&bamboo.PULL_REQUEST_VERSION=${PULL_REQUEST_VERSION}&bamboo.REPOSITORYSLUG=${PULL_REQUEST_AUTHOR_SLUG}&os_authType=basic&executeAllStages=true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But how do you get at the variables.e.g branch, which are passed as part of the hook?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe copy the way TeamCity implement this feature (available since 2013):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe this to be a rather standard feature. Are there any news?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There's presently no way of doing that without writing all the pieces yourself.
On Bamboo, you'll need the following configurations:
* Adding a shell script step to fetch the remote pull request references; they are considered internal use only, but that's the only way right now. More information in this question. I use the following:
git remote | grep -q origin || git remote add origin "https://${bamboo.user}:${bamboo.password}@${bambo.repo.url}" git fetch origin '+refs/pull-requests/*/merge-clean:refs/remotes/origin/pr/*' git fetch origin '+refs/pull-requests/*/from:refs/remotes/origin/pr-from/*'
* Checkout the desired pull request; that means adding a plan variable that can be used on the build tasks. For example, a variable "prnumber" would be used like this:
git checkout pr/${bamboo.prnumber}
* Update build status on Stash using the REST API. This article has everything that's needed, but note that "merge-clean" is what is going to be merged (and, thus, what one needs to build), but the build status on the pull request status on Stash only shows up for the source commit -- that's why I bring the two references above.
* Since there's no variable in Bamboo to indicate whether a build has succeeded or not, I use three steps: mark a build in progress after checkout, mark a build as succeeded as the last task, and then, on a final task (which is always run, whether the previous tasks succeed or not), I mark the build as failed if I don't find a file left behind indicating the build has succeeded (I use a file I create to store the json I send to Stash).
On the Stash side, things are more difficult because you have to listen to pull request events -- the existing hooks don't cover it. This question covers most of what's needed. Because you are not using the hook mechanism, you won't have access to the easy per-repository configuration it provides, so you'll have to write it yourself.
One last note: you use the "queue" REST interface on Bamboo to trigger the build from Stash. Look at your Bamboo's version API documentation here to see the details (a generic REST description found elsewhere doesn't go into that).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
Have you seen Integrating Bamboo with Stash and this blog post for branch builds?
I think they should cover setting up both sides of PR builds.
Regards,
Tom.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We've been looking through the docs fairly extensively; the problem is that we use a fork-branch-and-PR model, so the branch from which the merge is being request is not actually a branch of the repository that Bamboo is building; or at least its ref is not in refs/heads, which is what I suspect the Bamboo git plugin is working from to get the names of branches that it might need to build. So, using plan branches does not actually work.
And, while I thought I'd found a workaround, it didn't pan out. What we essentially need is for the bamboo plan branches integration to be able to read from refs/pull-requests/\d+/from as well as refs/heads
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To additionally clarify, here's the workflow we need to support:
(1) Joe creates a new fork of the upstream repository using Stash
(2) Joe creates a local clone of his fork
(3) Joe pushes a feature branch from his local clone to his fork
(4) Joe uses stash to create a pull request for his feature branch, targeting the upstream/master branch
(5) Bamboo notices and checks out the "from" code of the pull request
(6) Bamboo attempts to merge upstream/master to the PR'ed code. If the merge is conflicted, it puts a nasty comment into the PR, rejects it, whatever.
(7) If the merge succeeds, Bamboo attempts to build and run tests. If the build fails, it puts in it's cruel commentary and rejects the PR.
(8) If the build succeeds, Bamboo tells Stash that it did so. Celebration! The PR is one step closer to being merged.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kris,
I've been talking to Bryan about this offline, and in the very short-term suggested using ls-remote in a script to create real branches for the private PR merge refs. He mentioned that you might be looking at the Bamboo plugin, which is definitely a much better idea. Did you have any luck with your investigation?
Our eventual goal is to support pull requests as first class citizens, and the following issue might be of interest (you may want to follow/vote for it):
https://jira.atlassian.com/browse/BAM-11205
I've been following up with the Bamboo team to see what we can do to help support this common workflow.
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have gone a long way, mostly with lots of duct tape and help from other questions. On Bamboo, I have resorted to shell script steps to fetch the desired branches (the internal use-only refs/pull-requests/* stuff) and update build status through Stash REST API. On Stash, a plugin listening to pull request events is doing the job. There's still configuration to set up for the Stash plugin (per-repository build plans), however, which doesn't look simple.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.