I am new to BitBucket Server and wonder about the relationship between BitBucket Server and my actual project. I have BitBucket Server installed on my web server (where my development project lives) and have successfully connected to BitBucket Server from SourceTree, committed and pushed, etc.
What I don't understand is what I do next. I'd like that when I commit to my BitBucket Server repository, that updates the project development environment on the web server. With Git, I would just have the remote repository live in the folder on the web server where my project resides. How do I tell BitBucket Server to 'live' there?
Do I need Bamboo to accomplish this? I see that there is a Source Code Checkout task there. Or am I simply misunderstanding the workings of BitBucket Server?
All guidance is appreciated.
Thank you.
As you've discovered, Bitbucket Server doesn't work like "naked" Git. It's meant to be the home for many collaborators and many repositories. As such, it does "own" where it stores Git repositories. A while back, I wrote a blog post about triggering deployment with Git commands that might address your needs.
Yes, you could add Bamboo to the mix, especially if you have some form of tests you would want to run before deploying to your web server.
One more option you might consider would be to skip running your own Bitbucket Server, and use Bitbucket Cloud. Then you could leverage Bitbucket Pipelines to push your web code to your web server.
Hope that helps!
Thanks for your prompt response! Would it work just as well to use the Mirror Hook and just mirror the repo to a Git directory in my directory each time someone commits?
Also, any idea how to test hooks?
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, Bitbucket Server is the right fit for enterprise networks. Say no more.
The Mirror Hook sounds like the perfect solution. Sorry I had missed that. You should also be able to find the Mirror Hook as an add-on listed on the Marketplace:
https://marketplace.atlassian.com/plugins/com.englishtown.stash-hook-mirror/server/overview
As for testing, I would be more worried about monitoring. It's trivial to verify the result of a mirror once. But I think it's more interesting to know if a mirror has failed due to a network disruption or something. I think the easy approach is to wire your remote Git server (the web server) with a Git post-receive hook to call back to Bitbucket on every mirrored commit. I think something like this should work:
(Sorry, it's untested code, but shoot me a pull request if you find a serious error.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yup, that's the point of the post-receive hook. To send a "green build" back to Bitbucket when each commit gets mirrored.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm. But how do I set it up to send back a "green build"? I currently have the hook set up but don't see it working and get no feedback of whether it works or not...? Thank you so much for all your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It could be my error. I assumed you're running in a Bash world, not Windows. More importantly, I just removed `/bitbucket` from the start of the API URL path (if your Bitbucket is configured on a subpath, then include it in the BITBUCKET_URL, and make sure not to use a trailing slash) and added the `--verbose` switch to help with debugging.
Before configuring the hook, try putting some static values in for LAST_COMMIT_SHA (it must be the 40 char hash, not an abbreviation as found in the Bitbucket UI) and LAST_COMMIT_MESSAGE. Then you should be able to just run the script. After the URL fix, it works for me. On the command line, the script (now with verbose setting) should return an HTTP 204 response.
Once you find it working "manually", then you can configure the hook according to standard Git instructions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.