Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I connect BitBucket Server with my project?

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. 

1 answer

1 accepted

0 votes
Answer accepted
devpartisan Atlassian Team Aug 30, 2017

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! 

We can't skip running BitBucket Server since we need to run this on our own private server which is behind enterprise networks. 

devpartisan Atlassian Team Sep 01, 2017

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:

https://bitbucket.org/ian_buchanan/bitbucket-server-mirror-monitor-hook/src/master/post-receive?fileviewer=file-view-default

(Sorry, it's untested code, but shoot me a pull request if you find a serious error.)

Thank you so much for all your help. Any idea how to test if a hook 'worked'? Similar to testing that a Bamboo build was successful?

devpartisan Atlassian Team Sep 01, 2017

Yup, that's the point of the post-receive hook. To send a "green build" back to Bitbucket when each commit gets mirrored.

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.

devpartisan Atlassian Team Sep 05, 2017

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.

Sorry- to clarify, I meant that I have the Mirror Hook set up. How do I get a status message from it?

 

Thank you very much!

Suggest an answer

Log in or Sign up to
This widget could not be displayed.
TAGS
Community showcase
Posted in Bitbucket

How do you use the Bitbucket-Jira integration? How does it help your team?

Hey everyone, over the past year, we've added several new features on how you can use Bitbucket and Jira together. We'd love to know how you are using the integration and how it's helping your team...

921 views 5 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you