-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #616 from linear-b/fine/add-bitbucket-cloud-integr…
…ation Add Bitbucket Cloud Integration Support
- Loading branch information
Showing
10 changed files
with
228 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
title: How to Setup gitStream with Bitbucket | ||
description: Install gitStream to your Bitbucket workspace. | ||
--- | ||
# How to Setup gitStream with Bitbucket | ||
|
||
!!! info "gitStream for Bitbucket Cloud is currently in **beta**" | ||
|
||
If you're interested in automating your Bitbucket pull requests and enhancing your development workflow, please [contact our support team](mailto:[email protected]) to request access and receive setup instructions. | ||
We’d love to hear your feedback and collaborate to improve this integration during the beta phase. Thank you for your interest! | ||
|
||
!!! info "Prerequisites" | ||
|
||
1. Bitbucket Cloud account | ||
2. Bitbucket Pipelines enabled | ||
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. | ||
|
||
Bitbucket Installation Overview | ||
|
||
1. Designate a gitStream user account. | ||
2. Create a CM configuration file. | ||
3. Create a Bitbucket pipeline. | ||
4. Install the gitStream service. | ||
|
||
## Designate a gitStream User Account | ||
|
||
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. | ||
|
||
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. | ||
|
||
!!! tip "Use this account when you integrate gitStream" | ||
Make sure to use this account when authorizing Bitbucket in LinearB. | ||
|
||
## Create a CM Configuration File | ||
|
||
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`. | ||
|
||
!!! info "Configuration files go in the repo's root directory." | ||
Your `.cm` files should be placed in the repository's root directory. | ||
|
||
!!! example "Example Configuration" | ||
```yaml | ||
--8<-- "docs/downloads/gitstream-bb.cm" | ||
``` | ||
|
||
## Create a Bitbucket Pipeline | ||
|
||
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: | ||
|
||
```yaml | ||
--8<-- "docs/downloads/bitbucket-pipelines.yml" | ||
``` | ||
|
||
!!! warning "Note" | ||
The `add-label` action is not supported in Bitbucket as Bitbucket does not have a native labeling feature. | ||
|
||
## Install the gitStream Service | ||
|
||
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. | ||
|
||
## Next Step | ||
If you successfully complete these instructions, gitStream will now automate your code review workflows in Bitbucket. | ||
|
||
!!! tip "How gitStream Works" | ||
Read our guide, [How gitStream Works](/how-it-works/), for a deeper understanding of gitStream's capabilities and how to leverage them fully. | ||
|
||
## Additional Resources | ||
|
||
### Required Bitbucket Permissions | ||
|
||
The required permissions are: | ||
|
||
| Permissions | Reason | | ||
| ----------------- | -------------------------------------------------------------------------------------------- | | ||
| Read/Write API | To get notified on PR changes and allow gitStream to approve PRs once all conditions are met | | ||
| Read repository | To read and check rules over the code changes on monitored repositories | | ||
| Read user profile | Used to identify users | | ||
|
||
</markdown> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Code generated by gitStream - DO NOT EDIT | ||
|
||
image: atlassian/default-image:4 | ||
|
||
pipelines: | ||
# Pipelines that can only be triggered manually | ||
custom: | ||
gitstream: | ||
- variables: | ||
- name: client_payload | ||
description: the client payload | ||
- name: head_ref | ||
description: the head sha | ||
- name: base_ref | ||
description: The base sha | ||
- name: resolver_url | ||
description: the resolver url to pass results to | ||
- name: resolver_token | ||
description: Optional resolver token for resolver service | ||
- name: debug_mode | ||
description: Debug mode | ||
default: 'true' | ||
- name: oauth_token | ||
description: token to do operations in bitbucket | ||
- name: full_repo | ||
description: workspace/repo | ||
- step: | ||
name: /:\ gitstream workflow automation | ||
max-time: 15 | ||
clone: | ||
enabled: false | ||
services: | ||
- docker | ||
script: | ||
- git clone https://x-token-auth:[email protected]/$full_repo.git gitstream/repo | ||
- git clone https://x-token-auth:[email protected]/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG.git gitstream/cm | ||
- cd gitstream/repo | ||
- git fetch --all | ||
- git checkout $base_ref | ||
- git checkout $head_ref | ||
- docker pull gitstream/rules-engine:latest | ||
- | | ||
docker run -v $BITBUCKET_CLONE_DIR/gitstream:/code \ | ||
-e HEAD_REF=$head_ref \ | ||
-e BASE_REF=$base_ref \ | ||
-e CLIENT_PAYLOAD="$client_payload" \ | ||
-e RULES_RESOLVER_URL=$resolver_url \ | ||
-e RULES_RESOLVER_TOKEN=$resolver_token \ | ||
-e DEBUG_MODE=$debug_mode gitstream/rules-engine:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# -*- mode: yaml -*- | ||
# This example configuration provides basic automations to get started with gitStream. | ||
# View the gitStream quickstart for more examples: https://docs.gitstream.cm/examples/ | ||
manifest: | ||
version: 1.0 | ||
|
||
|
||
automations: | ||
# Add a comment that indicates how many minutes it will take to review the PR. | ||
estimated_time_to_review: | ||
if: | ||
- true | ||
run: | ||
- action: add-comment@v1 | ||
args: | ||
comment: "{{ calc.etr }} min review" | ||
|
||
# Inform PR authors when they fail to reference Jira tickets in the PR title or description. | ||
comment_missing_jira_info: | ||
if: | ||
- {{ not (has.jira_ticket_in_title or has.jira_ticket_in_desc) }} | ||
run: | ||
- action: add-comment@v1 | ||
args: | ||
comment: | | ||
This PR is missing a Jira ticket reference in the title or description. | ||
Please add a Jira ticket reference to the title or description of this PR. | ||
# Post a comment that lists the best experts for the files that were modified. | ||
explain_code_experts: | ||
if: | ||
- true | ||
run: | ||
- action: explain-code-experts@v1 | ||
args: | ||
gt: 10 | ||
|
||
|
||
# +----------------------------------------------------------------------------+ | ||
# | Custom Expressions | | ||
# | https://docs.gitstream.cm/how-it-works/#custom-expressions | | ||
# +----------------------------------------------------------------------------+ | ||
|
||
calc: | ||
etr: {{ branch | estimatedReviewTime }} | ||
|
||
has: | ||
jira_ticket_in_title: {{ pr.title | includes(regex=r/\b[A-Za-z]+-\d+\b/) }} | ||
jira_ticket_in_desc: {{ pr.description | includes(regex=r/atlassian.net\/browse\/\w{1,}-\d{3,4}/) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.