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

AzureCommentReporter vars reflect official Azure DevOps naming #2510

Merged
merged 8 commits into from Apr 2, 2023
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
1 change: 1 addition & 0 deletions .github/linters/.cspell.json
Expand Up @@ -451,6 +451,7 @@
"bottomrule",
"btxg",
"bucketname",
"BUILDID",
"buildx",
"builtins",
"cacache",
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -13,10 +13,12 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Medias

- Linter enhancements & fixes
- Changed vars in AzureCommentReporter to reflects official Azure DevOps naming convention + fallback to keep backward compatibility, see [#2509](https://github.com/oxsecurity/megalinter/issues/2509)

- Core

- Documentation
- Updated usage scenario for Azure DevOps, see [#2509](https://github.com/oxsecurity/megalinter/issues/2509)

- Linter versions upgrades
<!-- linter-versions-end -->
Expand Down Expand Up @@ -91,7 +93,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l

- Core
- Run CI linter jobs only on Pull requests to avoid doubling jobs

- Documentation
- mega-linter-runner: doc fix for env list of values, see [#2448](https://github.com/oxsecurity/megalinter/issues/2448), by @DariuszPorowski in <https://github.com/oxsecurity/megalinter/pull/2449>

Expand Down
48 changes: 23 additions & 25 deletions README.md
Expand Up @@ -12,7 +12,7 @@
<!-- header-logo-end -->
<!-- mega-linter-title-start -->

## MegaLinter, by [![OX Security](https://www.ox.security/wp-content/uploads/2022/06/logo.svg?ref=megalinter_readme)](https://www.ox.security/?ref=megalinter)
# MegaLinter, by [![OX Security](https://www.ox.security/wp-content/uploads/2022/06/logo.svg?ref=megalinter_readme)](https://www.ox.security/?ref=megalinter)

<!-- mega-linter-title-end -->
<!-- mega-linter-badges-start -->
Expand Down Expand Up @@ -73,7 +73,7 @@ _Github PR reporter_
<!-- table-of-contents-start -->
## Table of Contents

- [MegaLinter](#megalinter)
- [MegaLinter](#megalinter-by-)
- [Table of Contents](#table-of-contents)
- [Why MegaLinter](#why-megalinter)
- [Quick Start](#quick-start)
Expand All @@ -87,14 +87,15 @@ _Github PR reporter_
- [Upgrade to MegaLinter v6](#upgrade-to-megalinter-v6)
- [Manual installation](#manual-installation)
- [GitHub Action](#github-action)
- [Azure Pipelines](#azure-pipelines)
- [GitLab CI](#gitlab-ci)
- [Azure Pipelines](#azure-pipelines)
- [Jenkins](#jenkins)
- [Concourse](#concourse)
- [Pipeline step](#pipeline-step)
- [Use it as reusable task](#use-it-as-reusable-task)
- [Drone CI](#drone-ci)
- [Docker container](#docker)
- [(Optional) Adjusting trigger rules](#optional-adjusting-trigger-rules)
- [Docker container](#docker-container)
- [Run MegaLinter locally](#run-megalinter-locally)
- [Configuration](#configuration)
- [Common variables](#common-variables)
Expand All @@ -117,12 +118,15 @@ _Github PR reporter_
- [Create plugins](#create-plugins)
- [Limitations](#limitations)
- [Articles](#articles)
- [English](#english)
- [French](#french)
- [Videos](#videos)
- [Frequently Asked Questions](#frequently-asked-questions)
- [How to contribute](#how-to-contribute)
- [Special thanks](#special-thanks)
- [Contributors](#contributors)
- [Sites referring to MegaLinter](#sites-referring-to-megalinter)
- [Global](#global)
- [Web Sites](#web-sites)
- [Linters](#linters)
- [Open-source teams](#open-source-teams)
- [Super-Linter team](#super-linter-team)
Expand All @@ -139,7 +143,7 @@ _Github PR reporter_
- [Enhanced Documentation](#enhanced-documentation)
- [Plugins management](#plugins-management)
- [Simplify architecture and evolutive maintenance](#simplify-architecture-and-evolutive-maintenance)
- [Improve robustness & stability](#improve-robustness--stability)
- [Improve robustness \& stability](#improve-robustness--stability)
- [V4 versus V5](#v4-versus-v5)
<!-- table-of-contents-end -->

Expand Down Expand Up @@ -507,7 +511,6 @@ Create a Gitlab access token and define it in a variable **GITLAB_ACCESS_TOKEN_M

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


### Azure Pipelines

Use the following Azure Pipelines [YAML template](https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema)
Expand All @@ -527,15 +530,10 @@ Add the following job in your `azure-pipelines.yaml` file
# Run MegaLinter
- script: |
docker run -v $(System.DefaultWorkingDirectory):/tmp/lint \
-e GIT_AUTHORIZATION_BEARER=$(System.AccessToken) \
--env-file <(env | grep -e SYSTEM_ -e BUILD_ -e TF_ -e AGENT_) \
-e CI=true \
DariuszPorowski marked this conversation as resolved.
Show resolved Hide resolved
-e TF_BUILD=true \
-e SYSTEM_ACCESSTOKEN=$(System.AccessToken) \
-e SYSTEM_COLLECTIONURI=$(System.CollectionUri) \
-e SYSTEM_PULLREQUEST_PULLREQUESTID=$(System.PullRequest.PullRequestId) \
-e SYSTEM_TEAMPROJECT="$(System.TeamProject)" \
-e BUILD_BUILD_ID=$(Build.BuildId) \
-e BUILD_REPOSITORY_ID=$(Build.Repository.ID) \
-e GIT_AUTHORIZATION_BEARER=$(System.AccessToken) \
oxsecurity/megalinter:v6
displayName: Run MegaLinter

Expand Down Expand Up @@ -571,7 +569,7 @@ stage('MegaLinter') {
}
post {
always {
archiveArtifacts allowEmptyArchive: true, artifacts: 'mega-linter.log,megalinter-reports/**/*', defaultExcludes: false, followSymlinks: false
archiveArtifacts allowEmptyArchive: true, artifacts: 'mega-linter.log,megalinter-reports/**/*', defaultExcludes: false, followSymlinks: false
}
}
}
Expand Down Expand Up @@ -693,7 +691,7 @@ name: MegaLinter
workspace:
path: /tmp/lint

steps:
steps:

- name: megalinter
image: oxsecurity/megalinter:v6
Expand All @@ -715,13 +713,13 @@ name: MegaLinter
workspace:
path: /tmp/lint

steps:
steps:

- name: megalinter
image: oxsecurity/megalinter:v6
environment:
DEFAULT_WORKSPACE: /tmp/lint

trigger:
event:
- push
Expand Down Expand Up @@ -857,7 +855,7 @@ DISABLE: PHP
- Run all linters except PHP_PHPSTAN and PHP_PSALM linters

```yaml
DISABLE_LINTERS:
DISABLE_LINTERS:
- PHP_PHPSTAN
- PHP_PSALM
```
Expand Down Expand Up @@ -1037,6 +1035,7 @@ You can show MegaLinter status with a badge in your repository README
[![MegaLinter](https://github.com/oxsecurity/megalinter/workflows/MegaLinter/badge.svg?branch=main)](https://github.com/oxsecurity/megalinter/actions?query=workflow%3AMegaLinter+branch%3Amain)

_If your main branch is **master** , replace **main** by **master** in URLs_

### Markdown

- Format
Expand Down Expand Up @@ -1100,11 +1099,11 @@ PLUGINS:

### Plugins Catalog

* [jupyfmt](https://github.com/kpj/jupyfmt): The uncompromising Jupyter notebook formatter ([usage](https://github.com/kpj/jupyfmt#mega-linter-integration))
* [linkcheck](https://github.com/shiranr/linkcheck): Plugin to check and validate markdown links exist and working.
* [nitpick](https://github.com/andreoliwa/nitpick): Command-line tool and flake8 plugin to enforce the same settings across multiple language-independent projects. ([usage](https://github.com/andreoliwa/nitpick#run-as-a-megalinter-plugin))
* [mustache](https://github.com/one-acre-fund/mega-linter-plugin-logstash): Plugin to validate [Logstash](https://www.elastic.co/guide/en/logstash/current/configuration.html) pipeline definition files using [mustache](https://github.com/breml/logstash-config)
* [salt-lint](https://github.com/ssc-services/mega-linter-plugin-salt): Checks Salt State files (SLS) for best practices and behavior that could potentially be improved.
- [jupyfmt](https://github.com/kpj/jupyfmt): The uncompromising Jupyter notebook formatter ([usage](https://github.com/kpj/jupyfmt#mega-linter-integration))
- [linkcheck](https://github.com/shiranr/linkcheck): Plugin to check and validate markdown links exist and working.
- [nitpick](https://github.com/andreoliwa/nitpick): Command-line tool and flake8 plugin to enforce the same settings across multiple language-independent projects. ([usage](https://github.com/andreoliwa/nitpick#run-as-a-megalinter-plugin))
- [mustache](https://github.com/one-acre-fund/mega-linter-plugin-logstash): Plugin to validate [Logstash](https://www.elastic.co/guide/en/logstash/current/configuration.html) pipeline definition files using [mustache](https://github.com/breml/logstash-config)
- [salt-lint](https://github.com/ssc-services/mega-linter-plugin-salt): Checks Salt State files (SLS) for best practices and behavior that could potentially be improved.

Submit a PR if you want your plugin to appear here :)

Expand Down Expand Up @@ -1254,7 +1253,6 @@ description: List of all contributors, websites and linters that help MegaLinter
<img src="https://contrib.rocks/image?repo=oxsecurity/megalinter" />
</a>


### Sites referring to MegaLinter

#### Web Sites
Expand Down
17 changes: 6 additions & 11 deletions docs/installation.md
Expand Up @@ -192,15 +192,10 @@ Add the following job in your `azure-pipelines.yaml` file
# Run MegaLinter
- script: |
docker run -v $(System.DefaultWorkingDirectory):/tmp/lint \
-e GIT_AUTHORIZATION_BEARER=$(System.AccessToken) \
--env-file <(env | grep -e SYSTEM_ -e BUILD_ -e TF_ -e AGENT_) \
-e CI=true \
DariuszPorowski marked this conversation as resolved.
Show resolved Hide resolved
-e TF_BUILD=true \
-e SYSTEM_ACCESSTOKEN=$(System.AccessToken) \
-e SYSTEM_COLLECTIONURI=$(System.CollectionUri) \
-e SYSTEM_PULLREQUEST_PULLREQUESTID=$(System.PullRequest.PullRequestId) \
-e SYSTEM_TEAMPROJECT="$(System.TeamProject)" \
-e BUILD_BUILD_ID=$(Build.BuildId) \
-e BUILD_REPOSITORY_ID=$(Build.Repository.ID) \
-e GIT_AUTHORIZATION_BEARER=$(System.AccessToken) \
oxsecurity/megalinter:v6
displayName: Run MegaLinter

Expand Down Expand Up @@ -236,7 +231,7 @@ stage('MegaLinter') {
}
post {
always {
archiveArtifacts allowEmptyArchive: true, artifacts: 'mega-linter.log,megalinter-reports/**/*', defaultExcludes: false, followSymlinks: false
archiveArtifacts allowEmptyArchive: true, artifacts: 'mega-linter.log,megalinter-reports/**/*', defaultExcludes: false, followSymlinks: false
}
}
}
Expand Down Expand Up @@ -358,7 +353,7 @@ name: MegaLinter
workspace:
path: /tmp/lint

steps:
steps:

- name: megalinter
image: oxsecurity/megalinter:v6
Expand All @@ -380,13 +375,13 @@ name: MegaLinter
workspace:
path: /tmp/lint

steps:
steps:

- name: megalinter
image: oxsecurity/megalinter:v6
environment:
DEFAULT_WORKSPACE: /tmp/lint

trigger:
event:
- push
Expand Down
11 changes: 3 additions & 8 deletions docs/reporters/AzureCommentReporter.md
Expand Up @@ -22,15 +22,10 @@ Example:
```yaml
- script: |
docker run -v $(System.DefaultWorkingDirectory):/tmp/lint \
-e GIT_AUTHORIZATION_BEARER=$(System.AccessToken) \
--env-file <(env | grep -e SYSTEM_ -e BUILD_ -e TF_ -e AGENT_) \
-e CI=true \
-e TF_BUILD=true \
-e SYSTEM_ACCESSTOKEN=$(System.AccessToken) \
-e SYSTEM_COLLECTIONURI=$(System.CollectionUri) \
-e SYSTEM_PULLREQUEST_PULLREQUESTID=$(System.PullRequest.PullRequestId) \
-e SYSTEM_TEAMPROJECT="$(System.TeamProject)" \
-e BUILD_BUILD_ID=$(Build.BuildId) \
-e BUILD_REPOSITORY_ID=$(Build.Repository.ID) \
-e GIT_AUTHORIZATION_BEARER=$(System.AccessToken) \
oxsecurity/megalinter:v6
displayName: Run MegaLinter
```
Expand All @@ -47,4 +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` |
| REPORTERS_MARKDOWN_TYPE | Set to `simple` to avoid external images in generated markdown | `advanced` |
8 changes: 4 additions & 4 deletions megalinter/reporters/AzureCommentReporter.py
Expand Up @@ -8,7 +8,7 @@
- SYSTEM_COLLECTIONURI
- SYSTEM_PULLREQUEST_PULLREQUESTID
- SYSTEM_TEAMPROJECT
- BUILD_BUILD_ID
- BUILD_BUILDID
- BUILD_REPOSITORY_ID
"""
import logging
Expand Down Expand Up @@ -45,17 +45,17 @@ def produce_report(self):
)
SYSTEM_TEAMPROJECT = urllib.parse.quote(config.get("SYSTEM_TEAMPROJECT"))
BUILD_REPOSITORY_ID = config.get("BUILD_REPOSITORY_ID")
BUILD_BUILD_ID = config.get("BUILD_BUILD_ID")
BUILD_BUILDID = config.get("BUILD_BUILDID", config.get("BUILD_BUILD_ID"))
AZURE_COMMENT_REPORTER_LINKS_TYPE = config.get(
"AZURE_COMMENT_REPORTER_LINKS_TYPE", "artifacts"
)
if AZURE_COMMENT_REPORTER_LINKS_TYPE == "artifacts":
artifacts_url = (
f"{SYSTEM_COLLECTIONURI}{SYSTEM_TEAMPROJECT}/_build/results?buildId="
f"{BUILD_BUILD_ID}&view=artifacts&pathAsName=false&type=publishedArtifacts"
f"{BUILD_BUILDID}&view=artifacts&pathAsName=false&type=publishedArtifacts"
)
else:
artifacts_url = f"{SYSTEM_COLLECTIONURI}{SYSTEM_TEAMPROJECT}/_build/results?buildId={BUILD_BUILD_ID}"
artifacts_url = f"{SYSTEM_COLLECTIONURI}{SYSTEM_TEAMPROJECT}/_build/results?buildId={BUILD_BUILDID}"
url = (
f"{SYSTEM_COLLECTIONURI}{SYSTEM_TEAMPROJECT}/_apis/git/repositories/"
f"{BUILD_REPOSITORY_ID}/pullRequests/{SYSTEM_PULLREQUEST_PULLREQUESTID}"
Expand Down