Skip to content

Commit

Permalink
JOB_SUMMARY_ADDITIONAL_MARKDOWN (#4034)
Browse files Browse the repository at this point in the history
* JOB_SUMMARY_ADDITIONAL_MARKDOWN

Allow to add custom messages at the end of PR / MR MegaLinter Summary using variable **JOB_SUMMARY_ADDITIONAL_MARKDOWN**

Fixes #4028

* [MegaLinter] Apply linters fixes

---------

Co-authored-by: nvuillam <nvuillam@users.noreply.github.com>
  • Loading branch information
nvuillam and nvuillam authored Sep 23, 2024
1 parent d68f531 commit 0167c76
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Core
- Allow to tag PRE_COMMANDS to run them before loading plugins, by @nvuillam in <https://github.com/oxsecurity/megalinter/pull/3944>
- Replace usage of setup.py with a pyproject.toml package install, by @echoix in [#3893](https://github.com/oxsecurity/megalinter/pull/3893)
- Allow to add custom messages at the end of PR / MR MegaLinter Summary using variable **JOB_SUMMARY_ADDITIONAL_MARKDOWN**

- New linters
- New LUA linter: [**selene**](https://github.com/Kampfkarren/selene), by @AlejandroSuero in <https://github.com/oxsecurity/megalinter/pull/3978>
Expand Down
1 change: 1 addition & 0 deletions docs/reporters/AzureCommentReporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ Example:
| AZURE_COMMENT_REPORTER | Activates/deactivates reporter | true |
| AZURE_COMMENT_REPORTER_LINKS_TYPE | Set to `build` if you want comments linking to target Build and not artifacts page | `artifacts` |
| REPORTERS_MARKDOWN_TYPE | Set to `simple` to avoid external images in generated markdown | `advanced` |
| JOB_SUMMARY_ADDITIONAL_MARKDOWN | Custom markdown to add at the end of the summary message | <!-- --> |
1 change: 1 addition & 0 deletions docs/reporters/BitbucketCommentReporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ If you really want a new PR comment for each MegaLinter run, define variable `BI
| 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` |
| JOB_SUMMARY_ADDITIONAL_MARKDOWN | Custom markdown to add at the end of the summary message | <!-- --> |
3 changes: 2 additions & 1 deletion docs/reporters/GitHubCommentReporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Click on hyperlinks to access detailed logs
| GITHUB_API_URL | URL where the github API can be reached<br/>Must be overridden if using GitHub Enterprise | `https://api.github.com` | For GHE, use `https://my.company.com/api/v3` |
| GITHUB_SERVER_URL | URL of the GitHub instance<br/>Must be overridden if using GitHub Enterprise | `https://github.com` | |
| CI_ACTION_RUN_URL | URL of the CI job visualization page url (if using Github but not GitHub Actions) | <!-- --> | |
| REPORTERS_MARKDOWN_TYPE | Set to `simple` to avoid external images in generated markdown | `advanced` | |
| REPORTERS_MARKDOWN_TYPE | Set to `simple` to avoid external images in generated markdown | `advanced` | |
| JOB_SUMMARY_ADDITIONAL_MARKDOWN | Custom markdown to add at the end of the summary message | <!-- --> |
1 change: 1 addition & 0 deletions docs/reporters/GitlabCommentReporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ If you really want a new MR comment for each MegaLinter run, define variable `GI
| GITLAB_CUSTOM_CERTIFICATE | SSL certificate value to connect to Gitlab | <!-- --> |
| GITLAB_CERTIFICATE_PATH | Path to SSL certificate to connect to Gitlab (if SSL cert has been manually defined with PRE_COMMANDS) | <!-- --> |
| REPORTERS_MARKDOWN_TYPE | Set to `simple` to avoid external images in generated markdown | `advanced` |
| JOB_SUMMARY_ADDITIONAL_MARKDOWN | Custom markdown to add at the end of the summary message | <!-- --> |

## Special Thanks

Expand Down
9 changes: 5 additions & 4 deletions docs/reporters/MarkdownSummaryReporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Activate the reporter (`MARKDOWN_SUMMARY_REPORTER: true`) to generate markdown s

## Configuration

| Variable | Description | Default value |
|-------------------------------------|---------------------------------------------------|------------------------|
| MARKDOWN_SUMMARY_REPORTER | Activates/deactivates reporter | `false` |
| MARKDOWN_SUMMARY_REPORTER_FILE_NAME | File name for MARKDOWN_SUMMARY report output file | `megalinter-report.md` |
| Variable | Description | Default value |
|-------------------------------------|----------------------------------------------------------|------------------------|
| MARKDOWN_SUMMARY_REPORTER | Activates/deactivates reporter | `false` |
| MARKDOWN_SUMMARY_REPORTER_FILE_NAME | File name for MARKDOWN_SUMMARY report output file | `megalinter-report.md` |
| JOB_SUMMARY_ADDITIONAL_MARKDOWN | Custom markdown to add at the end of the summary message | <!-- --> |
Original file line number Diff line number Diff line change
Expand Up @@ -8138,6 +8138,12 @@
"title": "Pre commands for JAVA descriptor",
"type": "array"
},
"JOB_SUMMARY_ADDITIONAL_MARKDOWN": {
"$id": "#/properties/JOB_SUMMARY_ADDITIONAL_MARKDOWN",
"description": "Custom markdown to add at the end of the summary message posted on a PR/MR",
"title": "Job Summary additional markdown",
"type": "string"
},
"JSON_ESLINT_PLUGIN_JSONC_ARGUMENTS": {
"$id": "#/properties/JSON_ESLINT_PLUGIN_JSONC_ARGUMENTS",
"description": "JSON_ESLINT_PLUGIN_JSONC: User custom arguments to add in linter CLI call",
Expand Down
6 changes: 6 additions & 0 deletions megalinter/utils_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ def build_markdown_summary(reporter_self, action_run_url=""):
+ "(https://www.ox.security/wp-content/uploads/2022/06/"
+ "logo.svg?ref=megalinter_comment)](https://www.ox.security/?ref=megalinter)_"
)
if config.exists(
reporter_self.master.request_id, "JOB_SUMMARY_ADDITIONAL_MARKDOWN"
):
p_r_msg += os.linesep + config.get(
reporter_self.master.request_id, "JOB_SUMMARY_ADDITIONAL_MARKDOWN", ""
)
logging.debug("\n" + p_r_msg)
return p_r_msg

Expand Down

0 comments on commit 0167c76

Please sign in to comment.