Building From On-Premises Bitbucket Server Using Visual Studio Team Services

I was recently asked via Twitter if you could build from an on-premises Bitbucket server using Visual Studio Team Services.  The answer is yes and this post will show you how.

The only assumption I am making is you already have an on-premises Bitbucket server that is exposed to the internet.  This post is going to focus on establishing a connection to an on-premises Bitbucket server and not the project being built.

image_thumb4
  1. Log in to Team Services
  2. Click the Build hub
  3. Click the green plus 
  4. Select the Empty template
  5. Click Next
  6. Select Remote Git Repository
  7. Check the box for Continuous integration
  8. Click Create

With the build created, it is now time to connect Bitbucket to Team Services.

image
  1. Click the Repository tab
  2. Click Manage next to Connection
  3. Click New Service Endpoint
  4. Select External Git
    Field Value
    Connection Name Bitbucket
    Server URL http://{Bitbucket Server}:{Port}/scm/{Project}/{Repo}.git
    User Name [Username with permissions to repo]
    Password/Token Key [Password for user]
  5. Close tab
  6. Click Refresh button next to Manage
    Field Value
    Repository type External Git
    Connection Bitbucket
    Repository name [Leave empty, the system will fill it in]
    Default branch [Your desired branch]
    Clean [Select true or false]
    Checkout submodules [Check if you have submodules]
  7. Click Save
  8. Give your build a name
  9. Click OK
  10. Click Queue build…
  11. Click OK

As you can see from the screenshot below, Team Services was able to clone the on-premises Bitbucket repository.

image

Comments (13) -

  • the check box "continous integration" is not available if you select Remote Git Repository.
  • is it possible to connect to a on premise GitHub Enterprise ?
    the GitHub connection type does not allow to specify the name of the host and with Remote Git Repository connection type Continous Integration is not available as option
  • We have to have Web hooks for CI to work. I don't think we have for Bitbucket yet. I will have to play with GitHub Enterprise and get back to you.
  • Hi Donovan,

    Is there a way to set this up using SSH authentication?  HTTPS access is disabled on our Bitbucket Server installation, so we are forced to use SSH, however I cannot see how to set it up.
    • bump!  same question.  Can't find anything on the web about using SSH...
      • Same here. Though HTTPS is not disabled, I would like to use SSH. Any info on how it can be done would be appreciated.
        • I contacted the Build team and this is the response I got. "At the moment we do not support SSH for Git repos on the build agent." There was no ETA on when this would change.
          • Thank you for your response. I guess this means we have to use a service account that does not expire its password and use HTTP instead of SSH.
            • BTW, you can always disable the get source function provided by the agent and do get source yourself through SSH in a script.
  • Is there a way to do this without creating a new endpoint for every repo?  I'd rather have one endpoint overall, or at least one per project.
    • That is a good question.  I actually don't use bitbucket and only set up one repo to test this blog post. You might request that as a feature on UserVoice for VSTS. visualstudio.uservoice.com/.../330519-team-services
      • Thanks Donovan.  Unfortunately, waiting for updates might not be feasible.  I'm being pushed toward Concourse at my job, and I'm trying to prove out that TFS / Release Management works just as well.  But the lack of easy integration with our enterprise Bitbucket repos is making it difficult.  Not only do you have to create an endpoint for each repo, but there doesn't appear to be a way to use an SSH key for the authentication.  It's sad, as I've been using TFS for my CI pipeline for a few years now and really like it.
  • Just checking if anyone deal with following error after making sonarqube service connection on VSTS.

    I am getting following error while running the Prepare sonarqube analysis job on VSTS.
    [SQ] API GET '/api/server/version' failed, error was: {"code":"UNABLE_TO_VERIFY_LEAF_SIGNATURE

Add comment

Loading