Bitbucket Integration

Follow this guide to integrate Lintify with your Bitbucket repository using Bitbucket Pipelines.

Configuration Steps

1. Add Bitbucket Pipeline Configuration

Create or update your bitbucket-pipelines.yml file in your repository with the following content:

pipelines:
  pull-requests:
    '**':
      - step:
          name: Lintify Analysis
          image: docker:latest
          script:
            - git fetch origin $BITBUCKET_PR_DESTINATION_BRANCH
            - git diff origin/$BITBUCKET_PR_DESTINATION_BRANCH -- > diff.txt
            - docker run --rm \
              -e PLATFORM=bitbucket \
              -e API_TOKEN=$BITBUCKET_TOKEN \
              -e REPO_SLUG=$BITBUCKET_REPO_SLUG \
              -e PULL_REQUEST_ID=$BITBUCKET_PR_ID \
              -v $PWD/diff.txt:/app/diff.txt \
              lintify-image:latest analyze --diff /app/diff.txt

2. Configure Repository Variables

You'll need to configure the following repository variable in your Bitbucket repository settings:

  • BITBUCKET_TOKEN - Your Bitbucket access token with API permissions

Note: Other variables like BITBUCKET_REPO_SLUG and BITBUCKET_PR_ID are automatically provided by Bitbucket Pipelines.

3. Generate Access Token

To generate a Bitbucket access token:

  1. Go to Bitbucket Settings → Access tokens
  2. Click "Create token"
  3. Grant the following permissions:
    • Pull request: Read and Write
    • Repositories: Read
  4. Copy the token and add it as a repository variable

How It Works

  1. When a pull request is created or updated, the pipeline automatically triggers.
  2. The pipeline generates a diff between the source and target branches.
  3. Lintify analyzes the changes and posts comments directly on your pull request.

Troubleshooting

Common issues and their solutions:

Pipeline doesn't trigger

Ensure Bitbucket Pipelines is enabled for your repository and the configuration file is in the default branch.

Permission errors

Verify that your access token has the required permissions and is correctly configured as a repository variable.

Need More Help?

If you're experiencing issues with the Bitbucket integration, our support team is here to help.