BitBucket Pull Request

The SeaLights Pull Request Integration exposes Quality Risks to the developer as part of the Pull Request process, to be displayed and handled before the code is merged into the main branch.

Creating a Personal Access Token on BitBucket

  • Before making the required configurations on the Bitbucket on-premise installation, a Personal Access Token must be created for authentication with the dedicated SeaLights agent:

    • In BitBucket, click on the logged in user and select 'Manage Account'

    • On the Left hand side pane, select "Personal access tokens"

    • Create a new token to be used to show results in the Bitbucket UI:

circle-exclamation
circle-info

The application will not modify anything in your repositories and projects as it only requires Read access.

SeaLights Task Runner App Configuration

sl-taskrunner-cfg.json example

Once the configuration file is created, run the SeaLights task runner .jar file, specifying the configuration file created in the previous step:

Running the SeaLights Task Runner using a configuration file

Alternatively, the same parameters can be specified directly as Java params:

Running the SeaLights Task Runner using Java parameters

circle-info

See Task Runner Agent - Command Reference for full list of parameters.

Configuring the BitBucket Pull Request to compare data to SeaLights

The pull request job needs to run the SeaLights build scan and test listener for the test stages you want the analysis on. These results will be compared to the latest build you reported to SeaLights for the branch you are merging the Pull Request to. The difference between the pull request job and standard jobs is in how the session ID is created using Pull Request specific parameters.

Generating a session ID

You create the Pull Request build session ID by using the SeaLights Java Build Scanner (See: Downloading The Java Agent with the prConfig option:

Sample prConfig command

circle-exclamation
circle-info

See prConfig - Command Reference for full parameter details in Java agent, node agent or via the Sealights Jenkins plugin.

Pull Request parameters as seen on a Bitbucket page

You can easily identify the relevant values to pass to the Build Scanner based on the illustration below.

Pull Request parameters mapping with Bitbucket Environment variables

Bitbucket provides a set of default variables that are available for builds, and can be used in scripts. These variables are detailed in the official Bitbucket documentationarrow-up-right and can be used like below

Sealights PR Parameter
BitBucket Env. Variable
Comment

pullRequestNumber

BITBUCKET_PR_ID

latestCommit

BITBUCKET_COMMIT

repoUrl

BITBUCKET_REPO_SLUG

In some configurations, you may need to prepend the base URL of your repository, like "https://bitbucket.mycompany.int/arrow-up-right$BITBUCKET_REPO_SLUG"

targetBranch

BITBUCKET_PR_DESTINATION_BRANCH

This is the branch name itself and might need to have a prefix added (Like: "origin/") to match the branch that was provided to SeaLights when scanning the merged branch

Sample of Results on the BitBucket Pull Request page

At the completion of the analysis, Sealights insights will appear at the right hand side of the "Overview" section of your Pull Request. Clicking on this will open the Quality reports section. Results will appear similar to the one below:

Last updated

Was this helpful?