Automate Code review using Android Lint & Bitbucket pipeline in Bitbucket Pull Request(Continuous Integration)
Posting comments in the Bitbucket Pull-request based on the Android Lint XML report using continuous integration(Bitbucket Pipelines)
Getting started
For posting comments to the PR, the Danger Ruby plugin is used. To use this install Ruby & Bundler in your system and set the environment variable as needed.
Enable Bitbucket Pipeline
Go to the Bitbucket Repository Settings -> Pipelines ->Settings and enable the pipeline

Environment Variable
Set the environment variables to the Bitbucket Pipeline settings to give access to the danger library to post comments as mentioned below.
Bitbucket Repository Settings -> Pipelines -> Repository variables
DANGER_BITBUCKETCLOUD_USERNAME — Bitbucket cloud username
DANGER_BITBUCKETCLOUD_PASSWORD — Bitbucket cloud password
DANGER_BITBUCKETCLOUD_UUID — Bitbucket cloud account UUID.
Username & password credentials are the same which is used for the logging into the Bitbucket cloud.
DANGER_BITBUCKETCLOUD_UUID
To get the UUID, open browser and copy-paste the API https://api.bitbucket.org/2.0/user and press enter. It will ask for a username & password for authentication, enter the Bitbucket username & password, and press enter. It will display the account information of the user with UUID with curly braces.
{
"username": "sdfsdf",
"display_name": "sdfsd",
"has_2fa_enabled": null,
"nickname": "sdfsdf",
"is_staff": false,
"location": null,
"account_status": "active",
"type": "user",
"uuid": "{234dfsdf-23ef-452d-q234-42fd44ece345}"
}
For use in the environment variable, curly braces are optional for UUID.
Configuration
Open the Android project & create a file name bitbucket-pipelines.yml in the root project folder & use the following code.
The CI is configured to run only when PR is created or updated.
The first step will run the lintDebug Gradle task & generates a report in the app/build/reports/lint-results-debug.xml file. The second step will use the generated report to post comments using the Danger Ruby library.
Gemfile
Create a file named Gemfile in the Root project folder & add the ruby gem Danger & Danger Android Lint plugin. List of plugins awesome-danger
Add the file to git. After adding or removing dependency, run bundle install command in the terminal. Once the command executed, Gemfile.lock will be created. Add this file also to the git.
Dangerfile
Create a file named Dangerfile in the Root project folder. This file uses the danger-android_lint plugin to post comments in the PR. Refer to the Danger Android Lint plugin for its usage.
The above code will find all the files(reports per module) in the following pattern run the android_lint.lint.
After making all the changes, commit & push the code and Create PR. Wait for the pipeline to complete. Once completed, if issues exist, then comments will be posted.
You can see the list of pipelines running, failed, stopped in the Pipeline menu in the repository.

That’s all guys. Thank you for taking the time to read. Please let me know if this was helpful or if you have any questions or see any mistakes or things that could be done even better.