Skip to content

Commit b8100cb

Browse files
authored
Merge pull request #616 from linear-b/fine/add-bitbucket-cloud-integration
Add Bitbucket Cloud Integration Support
2 parents f9b6bcd + c33c265 commit b8100cb

File tree

10 files changed

+228
-51
lines changed

10 files changed

+228
-51
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Our research shows that code reviews are [the most consistent bottleneck in the
6161

6262
## 🚀 Get Started
6363

64-
gitStream is a GitHub / GitLab app that processes automations defined in Continuous Merge (CM) automation files contained in your git repos. You can test gitStream automations on your own PRs via the [gitStream playground](https://app.gitstream.cm/playground).
64+
gitStream is a GitHub / GitLab / Bitbucket app that processes automations defined in Continuous Merge (CM) automation files contained in your git repos. You can test gitStream automations on your own PRs via the [gitStream playground](https://app.gitstream.cm/playground).
6565

6666
If you're ready to install gitStream, or want to explore its automation capabilities, [head over to the docs](https://docs.gitstream.cm). You can have your first automation up and running in as little as 2 minutes.
6767

@@ -92,4 +92,4 @@ gitStream is a free product from the team at [LinearB](https://linearb.io/?utm_s
9292
<img alt="Novu Logo" src="https://raw.githubusercontent.com/linear-b/gitstream/a5d4aca7b923e5cd70c813df06dc70de97382d8c/docs/downloads/images/LinearB-logo-dark.png" width="280"/>
9393
</picture>
9494
</a>
95-
</div>
95+
</div>

docs/automation-actions.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,32 @@ Actions are the end results of the automation described in your `.cm` file.
1212

1313
- :fontawesome-brands-github: Supported on GitHub
1414
- :fontawesome-brands-gitlab: Supported on GitLab
15+
- :fontawesome-brands-bitbucket: Supported on Bitbucket
1516
- :fontawesome-solid-flask: Open beta - Feature is under development and currently available for all
1617

1718
## Overview
1819

1920
[`send-http-request`](#send-http-request) is executed immediately after the evaluation of the condition.
2021
For all other actions, gitStream executes the actions in the order they are listed per automation. If an action result fails, the following actions will not be executed.
2122

22-
- [`add-comment`](#add-comment) :fontawesome-brands-github: :fontawesome-brands-gitlab:
23+
- [`add-comment`](#add-comment) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
2324
- [`add-github-check`](#add-github-check) :fontawesome-brands-github:
2425
- [`add-label`](#add-label) :fontawesome-brands-github: :fontawesome-brands-gitlab:
2526
- [`add-labels`](#add-labels) :fontawesome-brands-github: :fontawesome-brands-gitlab:
26-
- [`add-reviewers`](#add-reviewers) :fontawesome-brands-github: :fontawesome-brands-gitlab:
27+
- [`add-reviewers`](#add-reviewers) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
2728
- [`add-thread`](#add-thread) :fontawesome-brands-gitlab:
28-
- [`approve`](#approve) :fontawesome-brands-github: :fontawesome-brands-gitlab:
29-
- [`close`](#close) :fontawesome-brands-github: :fontawesome-brands-gitlab:
30-
- [`explain-code-experts`](#explain-code-experts) :fontawesome-brands-github: :fontawesome-brands-gitlab:
31-
- [`merge`](#merge) :fontawesome-brands-github: :fontawesome-brands-gitlab:
32-
- [`request-changes`](#request-changes) :fontawesome-brands-github: :fontawesome-brands-gitlab:
29+
- [`approve`](#approve) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
30+
- [`close`](#close) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
31+
- [`explain-code-experts`](#explain-code-experts) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
32+
- [`merge`](#merge) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
33+
- [`request-changes`](#request-changes) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
3334
- [`require-reviewers`](#require-reviewers) :fontawesome-brands-github:
3435
- [`run-github-workflow`](#run-github-workflow) :fontawesome-brands-github:
35-
- [`send-http-request`](#send-http-request) :fontawesome-brands-github:
36-
- [`send-slack-message`](#send-slack-message) :fontawesome-brands-github:
36+
- [`send-http-request`](#send-http-request) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
37+
- [`send-slack-message`](#send-slack-message) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
3738
- [`set-required-approvals`](#set-required-approvals) :fontawesome-brands-github:
38-
- [`update-description`](#update-description) :fontawesome-brands-github:
39-
- [`update-title`](#update-title) :fontawesome-brands-github:
39+
- [`update-description`](#update-description) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
40+
- [`update-title`](#update-title) :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
4041

4142
!!! note
4243

@@ -60,7 +61,7 @@ automations:
6061

6162
## Reference
6263

63-
#### `add-comment` :fontawesome-brands-github: :fontawesome-brands-gitlab:
64+
#### `add-comment` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
6465

6566
This action, once triggered, adds a comment to the PR.
6667

@@ -156,7 +157,7 @@ This is a managed action, when a PR updates existing labels that were added by g
156157
</div>
157158

158159

159-
#### `add-reviewers` :fontawesome-brands-github: :fontawesome-brands-gitlab:
160+
#### `add-reviewers` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
160161

161162
This action, once triggered, sets a specific reviewer.
162163

@@ -211,7 +212,7 @@ automations:
211212
comment: "Please make sure this change request is documented before merging"
212213
```
213214

214-
#### `explain-code-experts` :fontawesome-brands-github: :fontawesome-brands-gitlab:
215+
#### `explain-code-experts` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
215216

216217
This action, shall add a comment with codeExperts suggestion. If the comment already exists, the comment shall be edited.
217218

@@ -236,7 +237,7 @@ automations:
236237
gt: 10
237238
```
238239

239-
#### `approve` :fontawesome-brands-github: :fontawesome-brands-gitlab:
240+
#### `approve` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
240241

241242
This action, once triggered, approves the PR for merge.
242243

@@ -251,7 +252,7 @@ automations:
251252
- action: approve@v1
252253
```
253254

254-
#### `close` :fontawesome-brands-github: :fontawesome-brands-gitlab:
255+
#### `close` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
255256

256257
This action, once triggered, close the PR without merging.
257258

@@ -269,7 +270,7 @@ automations:
269270
- action: close@v1
270271
```
271272

272-
#### `merge` :fontawesome-brands-github: :fontawesome-brands-gitlab:
273+
#### `merge` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
273274

274275
Once triggered, merge the PR if possible. It can be set to wait for all checks to pass or only required ones.
275276

@@ -294,7 +295,7 @@ automations:
294295
rebase_on_merge: true
295296
```
296297

297-
#### `request-changes` :fontawesome-brands-github: :fontawesome-brands-gitlab:
298+
#### `request-changes` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
298299

299300
This action, once triggered, requests changes on the PR. As long as request change is set, gitStream will block the PR merge.
300301

@@ -401,7 +402,7 @@ has:
401402
* We encourage you to use this action with [custom triggers](./execution-model.md#explicit-triggers)
402403
* To manually test the webhook dispatch, please [run the workflow](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow#running-a-workflow){:target="_blank"} before using it with gitStream.
403404

404-
#### `send-http-request` :fontawesome-brands-github:
405+
#### `send-http-request` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
405406

406407
The action, once triggered, sends an HTTP request to the specified URL
407408
<div class="filter-details" markdown=1>
@@ -431,7 +432,7 @@ automations:
431432
body: '{"text": "Hello, world!"}'
432433
```
433434

434-
#### `send-slack-message` :fontawesome-brands-github:
435+
#### `send-slack-message` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
435436

436437
The action, once triggered, sends a webhook with a message content to a Slack app.
437438
To use this action, [create a Slack app](https://api.slack.com/messaging/webhooks#getting_started) with Incoming Webhooks enabled. gitStream uses the webhook URL to send the message.
@@ -485,7 +486,7 @@ automations:
485486

486487
To allow this action to block merge, you should enable branch protection, and gitStream has to be set as required check in GitHub.
487488

488-
#### `update-description` :fontawesome-brands-github:
489+
#### `update-description` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
489490
This action, when triggered, updates the PR description with new content.
490491

491492
This is a managed action. When a PR updates, the existing comments that were added by gitStream are re-evaluated, and those that are not applicable are removed.
@@ -520,7 +521,7 @@ jira_ticket_from_title: {{ pr.title | capture(regex=r/\b[A-Za-z]+-\d+\b/) }}
520521
```
521522

522523

523-
#### `update-title` :fontawesome-brands-github:
524+
#### `update-title` :fontawesome-brands-github: :fontawesome-brands-gitlab: :fontawesome-brands-bitbucket:
524525
This action, when triggered, updates the PR title with new content.
525526

526527
This is a managed action. When a PR updates, the existing comments that were added by gitStream are re-evaluated, and those that are not applicable are removed.

docs/bitbucket-installation.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: How to Setup gitStream with Bitbucket
3+
description: Install gitStream to your Bitbucket workspace.
4+
---
5+
# How to Setup gitStream with Bitbucket
6+
7+
!!! info "gitStream for Bitbucket Cloud is currently in **beta**"
8+
9+
If you're interested in automating your Bitbucket pull requests and enhancing your development workflow, please [contact our support team](mailto:support@linearb.io) to request access and receive setup instructions.
10+
We’d love to hear your feedback and collaborate to improve this integration during the beta phase. Thank you for your interest!
11+
12+
!!! info "Prerequisites"
13+
14+
1. Bitbucket Cloud account
15+
2. Bitbucket Pipelines enabled
16+
3. <a href="https://app.linearb.io/login" target="_blank">Login</a>, or <a href="https://app.linearb.io/sign-up" target="_blank">create a free account</a> on the LinearB app, and follow the steps to connect gitStream using a Bitbucket integration.
17+
18+
Bitbucket Installation Overview
19+
20+
1. Designate a gitStream user account.
21+
2. Create a CM configuration file.
22+
3. Create a Bitbucket pipeline.
23+
4. Install the gitStream service.
24+
25+
## Designate a gitStream User Account
26+
27+
gitStream automation rules are executed on behalf of the user account configured when you install the gitStream service. This account must have the necessary permissions to the relevant repositories.
28+
29+
We recommend creating a dedicated service account to control access to individual repositories easily. You can also use your professional or personal Bitbucket account for this, which would result in all automations being executed under that account.
30+
31+
!!! tip "Use this account when you integrate gitStream"
32+
Make sure to use this account when authorizing Bitbucket in LinearB.
33+
34+
## Create a CM Configuration File
35+
36+
Create a `gitstream.cm` rules file in the root directory of your repository's default branch (usually `master` or `main`). This file will contain a YAML configuration that determines the workflows that run on your repositories. You can name the CM file anything you want as long as it ends in `.cm`.
37+
38+
!!! info "Configuration files go in the repo's root directory."
39+
Your `.cm` files should be placed in the repository's root directory.
40+
41+
!!! example "Example Configuration"
42+
```yaml
43+
--8<-- "docs/downloads/gitstream-bb.cm"
44+
```
45+
46+
## Create a Bitbucket Pipeline
47+
48+
Once your gitStream configuration file is set up, you need a Bitbucket Pipelines configuration file to trigger gitStream automations. Create a `bitbucket-pipelines.yml` file in your repository's default branch (usually `master` or `main`) and add the following configuration:
49+
50+
```yaml
51+
--8<-- "docs/downloads/bitbucket-pipelines.yml"
52+
```
53+
54+
!!! warning "Note"
55+
The `add-label` action is not supported in Bitbucket as Bitbucket does not have a native labeling feature.
56+
57+
## Install the gitStream Service
58+
59+
To complete the setup, install the gitStream service in your Bitbucket workspace. Follow the instructions provided in the LinearB app to connect your Bitbucket account and repositories to gitStream.
60+
61+
## Next Step
62+
If you successfully complete these instructions, gitStream will now automate your code review workflows in Bitbucket.
63+
64+
!!! tip "How gitStream Works"
65+
Read our guide, [How gitStream Works](/how-it-works/), for a deeper understanding of gitStream's capabilities and how to leverage them fully.
66+
67+
## Additional Resources
68+
69+
### Required Bitbucket Permissions
70+
71+
The required permissions are:
72+
73+
| Permissions | Reason |
74+
| ----------------- | -------------------------------------------------------------------------------------------- |
75+
| Read/Write API | To get notified on PR changes and allow gitStream to approve PRs once all conditions are met |
76+
| Read repository | To read and check rules over the code changes on monitored repositories |
77+
| Read user profile | Used to identify users |
78+
79+
</markdown>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Code generated by gitStream - DO NOT EDIT
2+
3+
image: atlassian/default-image:4
4+
5+
pipelines:
6+
# Pipelines that can only be triggered manually
7+
custom:
8+
gitstream:
9+
- variables:
10+
- name: client_payload
11+
description: the client payload
12+
- name: head_ref
13+
description: the head sha
14+
- name: base_ref
15+
description: The base sha
16+
- name: resolver_url
17+
description: the resolver url to pass results to
18+
- name: resolver_token
19+
description: Optional resolver token for resolver service
20+
- name: debug_mode
21+
description: Debug mode
22+
default: 'true'
23+
- name: oauth_token
24+
description: token to do operations in bitbucket
25+
- name: full_repo
26+
description: workspace/repo
27+
- step:
28+
name: /:\ gitstream workflow automation
29+
max-time: 15
30+
clone:
31+
enabled: false
32+
services:
33+
- docker
34+
script:
35+
- git clone https://x-token-auth:$oauth_token@bitbucket.org/$full_repo.git gitstream/repo
36+
- git clone https://x-token-auth:$oauth_token@bitbucket.org/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG.git gitstream/cm
37+
- cd gitstream/repo
38+
- git fetch --all
39+
- git checkout $base_ref
40+
- git checkout $head_ref
41+
- docker pull gitstream/rules-engine:latest
42+
- |
43+
docker run -v $BITBUCKET_CLONE_DIR/gitstream:/code \
44+
-e HEAD_REF=$head_ref \
45+
-e BASE_REF=$base_ref \
46+
-e CLIENT_PAYLOAD="$client_payload" \
47+
-e RULES_RESOLVER_URL=$resolver_url \
48+
-e RULES_RESOLVER_TOKEN=$resolver_token \
49+
-e DEBUG_MODE=$debug_mode gitstream/rules-engine:latest

docs/downloads/gitstream-bb.cm

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- mode: yaml -*-
2+
# This example configuration provides basic automations to get started with gitStream.
3+
# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/
4+
manifest:
5+
version: 1.0
6+
7+
8+
automations:
9+
# Add a comment that indicates how many minutes it will take to review the PR.
10+
estimated_time_to_review:
11+
if:
12+
- true
13+
run:
14+
- action: add-comment@v1
15+
args:
16+
comment: "{{ calc.etr }} min review"
17+
18+
# Inform PR authors when they fail to reference Jira tickets in the PR title or description.
19+
comment_missing_jira_info:
20+
if:
21+
- {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }}
22+
run:
23+
- action: add-comment@v1
24+
args:
25+
comment: |
26+
This PR is missing a Jira ticket reference in the title or description.
27+
Please add a Jira ticket reference to the title or description of this PR.
28+
29+
# Post a comment that lists the best experts for the files that were modified.
30+
explain_code_experts:
31+
if:
32+
- true
33+
run:
34+
- action: explain-code-experts@v1
35+
args:
36+
gt: 10
37+
38+
39+
# +----------------------------------------------------------------------------+
40+
# | Custom Expressions |
41+
# | https://docs.gitstream.cm/how-it-works/#custom-expressions |
42+
# +----------------------------------------------------------------------------+
43+
44+
calc:
45+
etr: {{ branch | estimatedReviewTime }}
46+
47+
has:
48+
jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }}
49+
jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }}

docs/faq.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,38 @@ Choose which repositories are permitted to use GitHub Actions.
1616

1717
## Does gitStream services have access to my code?
1818

19-
Like any other CI/CD automation, the source code is being scanned in the repo and is not shared with any external services. Only metadata that relates and affects the workflow is shared to allow rule based automation on the repo.
19+
Like any other CI/CD automation, the source code is being scanned in the repo and is not shared with any external services. Only metadata related to and affecting the workflow is shared to allow rule-based automation on the repo.
2020

2121
## Why does gitStream require permission to write code?
22-
In order to support automations that either Approve or Merge PRs, GitHub API requires code write scope.
22+
To support automations that either Approve or Merge PRs, the git providers require code write scope.
2323

2424
## What repos are supported?
2525

26-
Any repo in GitHub is supported. More Git providers are planned soon.
26+
gitStream supports repositories in GitHub, GitLab, and Bitbucket. Note that the `add-label` action is not supported in Bitbucket as it does not have a native labeling feature.
2727

2828
## Can I use gitStream with Merge Queues?
2929

3030
Yes. When a merge queue is used, and gitStream is set as a required check, gitStream automation will be invoked with the merge event. The automation will set gitStream to a `Completed` status and `Skipped` conclusion to allow the PR merge.
3131
![gitStream with Merge Queue](screenshots/merge-queue-check.png)
3232

33-
## Custom filter functions
34-
35-
Coming soon.
36-
3733
## Is there .cm syntax highlighting?
3834

39-
The `.cm` file use YAML with JINJA2, in order for your favorite editor to choose automatically the right syntax, you can use modelines.
35+
The `.cm` file uses YAML with JINJA2. For your favorite editor to automatically choose the right syntax, you can use modelines.
4036

4137
Add the following line to the top of the `.cm` file (the default has it already):
4238

4339
```
4440
# -*- mode: yaml -*-
4541
```
4642

47-
Get a plug-in that enable modelines, popular ones are:
43+
Get a plug-in that enables modelines. Popular ones are:
4844

4945
- VS Code: [Modelines](https://marketplace.visualstudio.com/items?itemName=chrislajoie.vscode-modelines)
5046
- Sublime Text: [CM syntax for ST4](https://packagecontrol.io/packages/Continuous%20Merge) or [Emacs-like Sublime Modeline](https://github.com/kvs/STEmacsModelines)
5147
- Vim [Modeline magic](https://vim.fandom.com/wiki/Modeline_magic)
5248

53-
## I have an issue I can't seem to solve, what should I do?
49+
## I have an issue I can't seem to solve. What should I do?
5450

55-
Go to our issues page and check if there are any similar issues already reported. If not, create a new issue with all the details so we can take a look.
51+
Go to our issues page and check if any similar issues are already reported. If not, create a new issue with all the details so we can take a look.
5652

5753
Found a bug? Create a new item in the [project's issues](https://github.com/linear-b/gitstream/issues)

0 commit comments

Comments
 (0)