Comparison: GitHub Actions vs BitBucket Pipelines vs GitLab CI/CD
Tags: devops, programming, git, codenewbie
Published: 2022-12-20 14:59:08

Today we will look into the development process and compare the three most popular continuous integration, testing, and rolling out your code. The article will help you determine if you need to make a choice or if you have already mastered one and want to learn more about the others.

### Brief summary:
The entry threshold plays an important role, unlike other factors. So:

**Gitlab CI/CD** - the optimal choice for most. It combines a balance of simplicity and a huge community of users;
**GitHub actions** - The most popular platform and is one of the most confusing in my opinion. It is not a coincidence that GitHub has the highest number of users and open source projects compared to other platforms;
**Bitbucket pipelines** - Atlassian's integrated toolkit allows you to create integrations between other Atlassian products on the fly. The work has its own peculiarities, designed for confident users;

### What do these platforms have in common:
Any of the tools discussed here will allow you to implement a working CI/CD pipeline, but its costs and operational costs are different.

**All of them:**

- designed for development;
- have a comfortable development environment with support in the browser;
- have components for encapsulation;
- have decent performance;
- All support _docker_;
- Self-Hosted Runners;
- All are using _YAML_;
- Allow you to create pipelines for the application quickly;

Let's stipulate about the **supported operating systems** right away: 

Not all platforms allow you to support the software development lifecycle, and usually, a Linux environment is enough for you. Still, in some cases, you will need other environments presets,  such as _Windows_ or _macOS_,  to be able to create applications for _iOS/Windows_.

- **Bitbucket Pipelines** supports Linux environments at the moment and for about half a year _Windows Server_ and a few months _mac OS_ and are quite raw for use in a production system

- **GitLab CI/CD** supports Linux, mac OS, and Windows Server

- **GitHub Actions** supports Linux, macOS, and Windows Server.

In this article I will try to focus on the functionality and features of a certain platform.

### Bitbucket Pipelines </br>

**Pros**:
- Built-in integrations between their products and third-party services using the Atlassian Marketplace;

**Cons**:
- This supports only linux;
- A [cache](https://bitbucket.org/blog/automatically-refresh-caches-when-build-dependencies-are-updated) is used that sometimes interferes with work;
- Restarting the whole pipeline or failed steps, inability to start one step

This is an example of a Bitbucket Pipelines file (Bitbucket Pipelines makes use of a YAML file `bitbucket-pipelines.yml` located at the root directory of the repository):

```
image: node:19.3.0-slim

pipelines:
  default:
    - step:
        name: delete cache if changes in the build dependencies
        script:
          - pipe: atlassian/bitbucket-clear-cache:3.1.1
            variables:
                 BITBUCKET_USERNAME: $BITBUCKET_USER_NAME
                 BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
                 CACHES: ["node"]
        condition:
          changesets:
            includePaths:
               - package.json
               - src/*
    - step:
        name: Build and test
        script:
          - npm install
          - npm test
  branches:
    main:
      - step:
          name: Hello
          script:
            - echo "Hello from Dev.to"
```


### GitLab CI/CD </br>

**Pros**:
- Simplicity for writing, a lot of examples for building a full-fledged pipeline;
- Auto DevOps;

**Cons**:
- A weak role model for the distribution of policies who can roll out in production;
- Has quite a lot of bugs;

```
default:
  image: node:19.3.0-slim

stages:
  - build
  - test

build-app:
  stage: build
  script:
    - npm install
    - echo "Hello from Dev.to"

test-app:
  stage: test
  script:
    - npm test
```

### GitHub Actions </br>

**Pros**:
- Has a large community. The most popular solution means that someone has already had this or that problem and most likely you will be able to solve your own;
- Actions marketplace;

**Cons**:
- It is not very features;
- Doesn’t offer very well API development;

```
name: Tests

on:
  workflow_dispatch:
  push:
    branches:
    - 'main'
  pull_request:
    branches:
    - 'main'

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - name: Install Dependencies
        run: sudo ./.github/workflows/node-apt.sh
      - name: Install
        run: npm install
      - name: Test
        run: |
          npm test
          echo "Hello from Dev.to"
```

### Syntax </br>

The syntax is similar in all three cases, but the devil is in the details. Each platform has its own nuances, and the expediency of switching from one platform will cost not only money but also time to comprehend the documentation and the author's ideas.

#### Significant points that I would highlight:
**Bitbucket**</br>
- Implicit use of variables for custom pipelines. This will not work the way you intended and you will have to drag environment variables through the artifacts for all the steps where they are needed.
- Bitbucket is delicate for building docker images, such settings should not confuse anyone who has had experience with bitbucket, you can refer to the official documentation for more details.

```
options:
  docker: true
  size: 2x

definitions:
  services:
   docker:
     memory: 6144
```
So let's talk about features of **Gitlab**:</br>
- When a business grows out of a startup scale and begins to store a bunch of personal information, various federal laws of the company's country and certifications in the field of information security apply. It turns out that a role model is needed, the division of responsibilities of who rolls out, tests and who writes the code (which is not a common GitOps approach). Gitlab has only a few permissions and roles.
 
Gitlab has only a few [permissions and roles](https://docs.gitlab.com/ee/user/permissions.html)

What about **Github**:</br>
- Some valuable features of GitHub are paid, which is why most people stopped using it.
- It will be the most difficult if you are still bothered to read and use the GitHub API. Large JSON layers that need to be extracted must be sorted out and transformed into a working object.

### Conclusion:</br>
Now that you've figured out the platforms, let's see which one is right for you and your company.

If you are going to work only on home projects or open source, Github will be an excellent choice for you without a doubt.
While GitLab can be used if you are an enterprise. If you are someone who wants to host multiple repositories and work with many colleagues, then GitLab may be a good choice for you. Gitlab is the youngest project of all and follows the GitOps approach.

BitBucket is popular among many large organizations because of its user interface and integration.

But, to be honest, this question should be answered by you. It depends on your requirements, the size of the team and your niche.

If you are a developer, outsourcing, consulting company, you will need good integration with a project management tool, an error reporting tool, a text editor tool, etc. Check if you can integrate your project management tool such as Trello, Jira, and then take the following steps to make a decision.

Based on syntax, interface, functions, Gitlab CI/CD is one of the most fashionable and young compared to others. It is commonly used in startups and medium-sized companies. When it comes to a large enterprise, we tend to choose something more reliable, stable and user-tested to avoid the above problems.