Recently we witnessed a growing interest in GitLab and especially in its advanced built-in CI/CD component. To answer that interest, we have written a few papers on that topic and held several meetings (all of them recorded). As a result we were asked a number of questions about GitLab CI/CD.
In this paper I want to address one of those questions, whether it is possible to integrate Bitbucket with GitLab CI/CD. In other words, is it possible to keep your code in Bitbucket and use CI/CD of GitLab? Actually, this question is often extended to whether it is possible to connect Bitbucket + Jira + GitLab CI/CD, because many Bitbucket users use Jira as well.
The answer is a resolute Yes.
We have studied that issue and will show the way to do it.
From what we have seen, whenever the question about Bitbucket integration with GitLab CI/CD is asked, often the situation is as follows:
The company already uses Bitbucket in combination with Jenkins and wants to replace Jenkins with a more modern tool. On the other hand, they don’t want to part with Bitbucket, because they have already invested in adapting Bitbucket to their needs (in spite of GitLab being an excellent replacement for Bitbucket too; in the past, we have written several papers about it and also recorded a case study of a company, which did such a switch ( see the link below).
A Bitbucket to GitLab CI/CD connection is possible both for the public cloud version of Bitbucket (on atlassian.com) and for the self-hosted one. By “self-hosted” we mean a situation when Bitbucket is installed on a company’s own server, whether the latter is on-premises or is a private server on a cloud. Actually, the connection is possible for any combination of GitLab CI/CD and Bitbucket.
The connection is made possible by the following GitLab features:
- GitLab CI/CD for external repositories (added in March 2018)
- Remote repository pull mirroring (exists since 2017)
Based on our experience, we recommend building a plan on how you are going to use those features. In particular your development procedures, use of CI/CD, user training, etc. The second feature, pull mirroring, also requires thorough planning.
How will it all work together?
The following diagram shows the process we have built and often present to companies, which we advise on the development and CI/CD processes. This process is very basic and is supposed to be modified according to projects’ specific needs, but it already shows all “classic quartet” (see the link below) steps.
Here is an explanation of this diagram:
- The group leader creates an issue in JIRA to fix a bug or develop a feature and assigns it to a developer. The issue is in the “To Do” status.
- The developer starts working. He moves the issue to status “Doing”, then creates a branch and clones or pulls the repo to his workstation.
- After the feature is developed/the bug is fixed, the developer pushes his work to the Bitbucket server, which triggers a CI pipeline.
- If the pipeline succeeds, the developer creates a Pull Request, thus starting a code review.
- As a result of the code review, the developer may be requested to do a number of changes before the Pull Request is merged, with each change triggering a CI pipeline.
- At last, the Pull Request is merged into the master branch, and again a CI pipeline runs to check the merge result.
- Some changes may be needed on the master branch, after which the software is marked as a new baseline and the JIRA issue is marked as “Done”
- Note that there can be many variations on this flow. E.g., there can be an additional JIRA status, “QA Testing” to which the issue moves when a Pull Request is merged.
Summing up (and adding some points we have learned in our tests):
- It is possible to integrate Bitbucket with GitLab CI/CD (thus taking advantage of all GitLab CI/CD features).
- It is possible to integrate Jira + Bitbucket + GitLab CI/CD.
- It is possible to integrate Jira with GitLab (in the past we had written a paper on that topic and published a video demonstrating that integration).
- Alternatively, you can use GitLab as an all-in-one tool, which replaces Jira + Bitbucket + Jenkins.
- Similarly, it is possible to integrate GitLab CI/CD with any git server (e.g., , gitolite, gerrit, etc.)
- Does it pay off to stay with Bitbucket? Not sure. It depends on a number of factors (you can consult with us).