Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new reporter: BITBUCKET_COMMENT_REPORTER Reporter #3256

Merged
merged 18 commits into from Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cspell.json
Expand Up @@ -358,6 +358,7 @@
"PSHOME",
"PSSA",
"PULLREQUEST",
"pullrequests",
"PULLREQUESTID",
"PWSH",
"PYLINT",
Expand All @@ -367,6 +368,7 @@
"PYTHONPATH",
"PYTHONPYCACHEPREFIX",
"PYTYPE",
"pagelen",
"Pansino",
"Parallelly",
"Philipp",
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -8,7 +8,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image

- New reporter **MARKDOWN_SUMMARY_REPORTER**, allows saving MegaLinter results summary as a markdown file. This file can be further used to add comments on the pull request (PR) from Jenkins and other continuous integration (CI) tools.
- New reporter **MARKDOWN_SUMMARY_REPORTER**, allows saving MegaLinter results summary as a markdown file. This file can be further utilised to add comments on the pull request (PR) from Jenkins and other continuous integration (CI) tools.

- New reporter **BITBUCKET_COMMENT_REPORTER** allowing to post MegaLinter results as comments on Bitbucket pull requests.

- Core
- mega-linter-runner: Remove container by default, except of `no-remove-container` option is sent
Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -1287,6 +1287,7 @@ MegaLinter can generate various reports that you can activate / deactivate and c
| [GitHub Pull Request comments](https://github.com/oxsecurity/megalinter/tree/main/docs/reporters/GitHubCommentReporter.md) | MegaLinter posts a comment on the PR with a summary of lint results, and links to detailed logs | Active if GitHub Action |
| [Gitlab Merge Request comments](https://github.com/oxsecurity/megalinter/tree/main/docs/reporters/GitlabCommentReporter.md) | Mega-Linter posts a comment on the MR with a summary of lint results, and links to detailed logs | Active if in Gitlab CI |
| [Azure Pipelines Pull Request comments](https://github.com/oxsecurity/megalinter/tree/main/docs/reporters/AzureCommentReporter.md) | Mega-Linter posts a comment on the PR with a summary of lint results, and links to detailed logs | Active if in Azure Pipelines |
| [Bitbucket Pull Request comments](docs/reporters/BitbucketCommentReporter.md) | Mega-Linter posts a comment on the PR with a summary of lint results, and links to detailed logs | Active if in Bitbucket CI |
| [Updated sources](https://github.com/oxsecurity/megalinter/tree/main/docs/reporters/UpdatedSourcesReporter.md) | Zip containing **all formatted and autofixed sources** so you can extract them in your repository | Active |
| [IDE Configuration](https://github.com/oxsecurity/megalinter/tree/main/docs/reporters/ConfigReporter.md) | Apply MegaLinter configuration in your local IDE with linter config files and IDE extensions | Active |
| [GitHub Status](https://github.com/oxsecurity/megalinter/tree/main/docs/reporters/GitHubStatusReporter.md) | One GitHub status by linter on the PR, with links to detailed logs | Active if GitHub Action |
Expand Down Expand Up @@ -1721,6 +1722,10 @@ MegaLinter can be run locally thanks to [mega-linter-runner](https://megalinter.

![Screenshot](https://github.com/oxsecurity/megalinter/blob/main/docs/assets/images/GitlabCommentReporter.jpg?raw=true)

- [Bitbucket Pull Request comments](docs/reporters/BitbucketCommentReporter.md)

![Screenshot](docs/assets/images/BitbucketCommentReporter.png)

- [Azure Pull Request comments](https://github.com/oxsecurity/megalinter/tree/main/docs/reporters/AzureCommentReporter.md)

![Screenshot](https://github.com/oxsecurity/megalinter/blob/main/docs/assets/images/AzureCommentReporter.jpg?raw=true)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/mega-linter-vs-super-linter.md
Expand Up @@ -65,6 +65,10 @@ MegaLinter can be run locally thanks to [mega-linter-runner](https://megalinter.

![Screenshot](https://github.com/oxsecurity/megalinter/blob/main/docs/assets/images/AzureCommentReporter.jpg?raw=true)

- [Bitbucket Pull Request comments](./reporters/BitbucketCommentReporter.md)

![Screenshot](./assets/images/BitbucketCommentReporter.png)

- [Markdown Summary](docs/reporters/MarkdownSummaryReporter.md)

![Screenshot](docs/assets/images/MarkdownSummaryReporter_2.png)
Expand Down
34 changes: 17 additions & 17 deletions docs/reporters.md
Expand Up @@ -10,21 +10,21 @@ description: "List of all available reporters: Text, SARIF, TAP, GitHub, Gitlab,

MegaLinter can generate various reports that you can activate / deactivate and customize

| Reporter | Description | Default |
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|------------------------------|
| [Text files](reporters/TextReporter.md) | Generates **One log file by linter** + suggestions for fixes that can not be automated | Active |
| [SARIF (beta)](reporters/SarifReporter.md) | Generates an aggregated SARIF output file | Inactive |
| [GitHub Pull Request comments](reporters/GitHubCommentReporter.md) | MegaLinter posts a comment on the PR with a summary of lint results, and links to detailed logs | Active if GitHub Action |
| [Gitlab Merge Request comments](reporters/GitlabCommentReporter.md) | Mega-Linter posts a comment on the MR with a summary of lint results, and links to detailed logs | Active if in Gitlab CI |
| [Azure Pipelines Pull Request comments](reporters/AzureCommentReporter.md) | Mega-Linter posts a comment on the PR with a summary of lint results, and links to detailed logs | Active if in Azure Pipelines |
| [Updated sources](reporters/UpdatedSourcesReporter.md) | Zip containing **all formatted and autofixed sources** so you can extract them in your repository | Active |
| [IDE Configuration](reporters/ConfigReporter.md) | Apply MegaLinter configuration in your local IDE with linter config files and IDE extensions | Active |
| [GitHub Status](reporters/GitHubStatusReporter.md) | One GitHub status by linter on the PR, with links to detailed logs | Active if GitHub Action |
| [File.io](reporters/FileIoReporter.md) | **Send reports on file.io** so you can access them with a simple hyperlink provided at the end of console log | Inactive |
| [JSON](reporters/JsonReporter.md) | Generates a JSON output report file | Inactive |
| [Email](reporters/EmailReporter.md) | Receive **all reports on your e-mail**, if you can not use artifacts | Active |
| [TAP files](reporters/TapReporter.md) | One file by linter following [**Test Anything Protocol**](https://testanything.org/) format | Active |
| [Console](reporters/ConsoleReporter.md) | **Execution logs** visible in **console** with **summary table** and **links to other reports** at the end | Active |
| [Markdown Summary](docs/reporters/MarkdownSummaryReporter.md) | Generates a Markdown summary report file | Inactive |

| Reporter | Description | Default |
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|----------------------------------|
| [Text files](reporters/TextReporter.md) | Generates **One log file by linter** + suggestions for fixes that can not be automated | Active |
| [SARIF (beta)](reporters/SarifReporter.md) | Generates an aggregated SARIF output file | Inactive |
| [GitHub Pull Request comments](reporters/GitHubCommentReporter.md) | MegaLinter posts a comment on the PR with a summary of lint results, and links to detailed logs | Active if GitHub Action |
| [Gitlab Merge Request comments](reporters/GitlabCommentReporter.md) | Mega-Linter posts a comment on the MR with a summary of lint results, and links to detailed logs | Active if in Gitlab CI |
| [Azure Pipelines Pull Request comments](reporters/AzureCommentReporter.md) | Mega-Linter posts a comment on the PR with a summary of lint results, and links to detailed logs | Active if in Azure Pipelines |
| [Bitbucket Pull Request comments](./reporters/BitbucketCommentReporter.md) | Mega-Linter posts a comment on the PR with a summary of lint results, and links to detailed logs | Active if in Bitbucket Pipelines |
| [Updated sources](reporters/UpdatedSourcesReporter.md) | Zip containing **all formatted and autofixed sources** so you can extract them in your repository | Active |
| [IDE Configuration](reporters/ConfigReporter.md) | Apply MegaLinter configuration in your local IDE with linter config files and IDE extensions | Active |
| [GitHub Status](reporters/GitHubStatusReporter.md) | One GitHub status by linter on the PR, with links to detailed logs | Active if GitHub Action |
| [File.io](reporters/FileIoReporter.md) | **Send reports on file.io** so you can access them with a simple hyperlink provided at the end of console log | Inactive |
| [JSON](reporters/JsonReporter.md) | Generates a JSON output report file | Inactive |
| [Email](reporters/EmailReporter.md) | Receive **all reports on your e-mail**, if you can not use artifacts | Active |
| [TAP files](reporters/TapReporter.md) | One file by linter following [**Test Anything Protocol**](https://testanything.org/) format | Active |
| [Console](reporters/ConsoleReporter.md) | **Execution logs** visible in **console** with **summary table** and **links to other reports** at the end | Active |
| [Markdown Summary](./reporters/MarkdownSummaryReporter.md) | Generates a Markdown summary report file | Inactive |
<!-- reporters-section-end -->
29 changes: 29 additions & 0 deletions docs/reporters/BitbucketCommentReporter.md
@@ -0,0 +1,29 @@
---
title: Bitbucket Pull Request Comments Reporter for MegaLinter
description: Posts MegaLinter SAST results summary in the comments of the related Bitbucket Pull Request (if existing)
---
<!-- markdownlint-disable MD013 MD033 MD041 -->
# Bitbucket Comment Reporter

Posts MegaLinter results summary in the comments of the related Bitbucket pull request (if existing)

## Usage

Click on hyperlinks to access detailed logs (click on **Download** in **Artifacts section** at the left of a CI job page)

![Screenshot](../assets/images/BitbucketCommentReporter.png)

After a first MegaLinter run, a comment is posted on the PR. To avoid multiplicating MegaLinter PR comments, future MegaLinter runs will update the existing PR comment instead of posting a new one.

If you really want a new PR comment for each MegaLinter run, define variable `BITBUCKET_COMMENT_REPORTER_OVERWRITE_COMMENT` to `false`.

## Configuration

- [Create a Repository Access Token](https://support.atlassian.com/bitbucket-cloud/docs/create-a-repository-access-token/) with scope **Pull-requests: Write**
- Paste the access token in a [masked CI/CD variable](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/) named **BITBUCKET_REPO_ACCESS_TOKEN** in your project (repository)

| Variable | Description | Default value |
|----------------------------------------------|----------------------------------------------------------------------------------------------|---------------|
| BITBUCKET_COMMENT_REPORTER | Activates/deactivates reporter | `true` |
| BITBUCKET_REPO_ACCESS_TOKEN | Must contain a Bitbucket repository access token defined with api access | <!-- --> |
| BITBUCKET_COMMENT_REPORTER_OVERWRITE_COMMENT | Set to false to not overwrite existing comments in case of new runs on the same Pull Request | `true` |
Expand Up @@ -1416,6 +1416,20 @@
"title": "Including regex filter for BICEP descriptor",
"type": "string"
},
"BITBUCKET_COMMENT_REPORTER": {
"$id": "#/properties/BITBUCKET_COMMENT_REPORTER",
"default": true,
"description": "Posts Mega-Linter results summary in the comments of the related pull request (if existing)",
"title": "Activate Bitbucket PR Comments reporter",
"type": "boolean"
},
"BITBUCKET_COMMENT_REPORTER_OVERWRITE_COMMENT": {
"$id": "#/properties/BITBUCKET_COMMENT_REPORTER_OVERWRITE_COMMENT",
"default": true,
"description": "Set to false to disable the overwrite of existing MegaLinter Pull Request comment in case of new run",
"title": "Overwrite Bitbucket Pull Request Comment",
"type": "boolean"
},
"CLEAR_REPORT_FOLDER": {
"$id": "#/properties/CLEAR_REPORT_FOLDER",
"default": false,
Expand Down