A Bitbucket pipeline pipe to publish build-generated content as comments to a PR
7.6K
This Bitbucket pipeline pipe allow you to publish content generated in your bitbucket pipeline as a comment to the Pull Request that triggered the build.
Usage example of this pipe include publishing a comment containing a list of changes that would be caused by a merge of a Pull Request. This is particularily valuable for repositories containing configuration for an Infrastructure as Code solution such as Terraform or CloudFormation.
In that case, the list of changes would be created as an artifact of the build as a text file (Markdown syntax is supported), and the pipe would be configured to publish that text file as a comment on each build of the Pull Request.
A bitbucket account to be used to publish the comment. It is recommended to create an Application Password dedicated to the pipe in order to limit the privileges. The Pull Request: write permissions is needed.
To publish a comment to all Pull Requests, add the following snippet to the script section of your bitbucket-pipelines.yml file:
pipelines:
pull-requests:
'**':
- step:
services:
- docker
script:
- pipe: docker://endemics/bbc-comment-pipe:latest
variables:
BB_USER: $BB_USER
BB_APP_KEY: $BB_APP_KEY
FILE: "./artifact/comment.md"
| Variable | Usage |
|---|---|
| BB_USER (*) | The name of the Bitbucket user used to published the comment. A service account is recommended |
| BB_APP_KEY (*) | The password or application key for the bitbucket user used to publish the comment. Application keys recommended |
| FILE (*) | Path to the file you want to publish as a comment. Only text files at the moment. Markdown syntax is supported |
(*) = required variable.
Variables that should automatically be set by Bitbucket pipeline
| Variable | Usage |
|---|---|
| BITBUCKET_REPO_SLUG (*) | The URL-friendly version of the repository name. Should be automatically populated by Bitbucket pipeline |
| BITBUCKET_WORKSPACE (*) | The name of the workspace in which the repository lives.. Should be automatically populated by Bitbucket pipeline |
| BITBUCKET_PR_ID (*) | The pull request ID. Should be automatically populated by Bitbucket pipeline on a Pull Request trigger |
(*) = required variable.
Content type
Image
Digest
sha256:9770050c4…
Size
4.9 MB
Last updated
about 4 years ago
docker pull endemics/bbc-comment-pipe