JetBrains / Qodana

📝 Source repository of Qodana Help
https://www.jetbrains.com/help/qodana
Apache License 2.0
389 stars 63 forks source link

Expand GitLab examples #86

Closed Griefed closed 2 years ago

Griefed commented 2 years ago

Provide an additional example for a Qodana job in GitLabs CI/CD environment, which uses the expose_as-keyword to make a Qodana report availabe in a given, related, merge request.

Additionally link to a post which also gives an example on how a Discord webhook notification can be sent whenever a new Qodana report is available.

Griefed commented 2 years ago

The information added is essentially the same as the one mentioned in the already linked article by Riccardo Padovani, but adjusted for newer versions of Qodana. The example by Riccardo is no longer up to date:

However, the core of Riccardos example is still a valid one, hence the update to it, including screenshots.

To get an idea of how my changes would look like, see below:


Basic Example

To add a Qodana runner to a GitLab CI/CD pipeline, use the following configuration example: (.gitlab-ci.yml):

    qodana:
     image: 
       name: jetbrains/qodana-<linter>
       entrypoint: ['']
     script:
       - /opt/idea/bin/entrypoint --results-dir=$CI_PROJECT_DIR/qodana --save-report --report-dir=$CI_PROJECT_DIR/qodana/report
     artifacts:
       paths:
         - qodana

Exposing a Qodana report

In order for a report to be available in any given merge request, you need to make use of the expose_as-keyword and change the path to the artifacts. This will render the report available in any affiliated merge request: (.gitlab-ci.yml):

    qodana:
     image:
       name: jetbrains/qodana-<linter>
       entrypoint: ['']
     script:
       - /opt/idea/bin/entrypoint --results-dir=$CI_PROJECT_DIR/qodana --save-report --report-dir=$CI_PROJECT_DIR/qodana/report
     artifacts:
       paths:
         - qodana/report/
       expose_as: 'Qodana report'

Assuming you have configured your pipeline in a similar manner, this is what it may look like:

  1. Qodana report affiliated with a pipeline in a merge request

    Qodana report affiliated with a pipeline in a merge request
  2. Available actions for a given exposed Qodana artifact

    Available actions for a given exposed Qodana artifact

See also

External Links

'Integrating JetBrains Qodana with GitLab pipelines' by Riccardo Padovani 'Qodana, GitLab and Discord' by Griefed

tiulpin commented 2 years ago

Hi, @Griefed. Thank you for your updates. Please sign https://www.jetbrains.com/agreements/cla/ and we'll be able to proceed with merging your pull request.

@smth-to-smb could you review the changes, please?

Griefed commented 2 years ago

Hi, @Griefed. Thank you for your updates. Please sign https://www.jetbrains.com/agreements/cla/ and we'll be able to proceed with merging your pull request.

@smth-to-smb could you review the changes, please?

Hey tiulpin,

I've signed the request already. An agreement for Griefed should already exist. :)

I'll check the merge conflict due to the branch-change, too. It may take a couple of days though as I am currently suffering from je olde Covid.

Cheers Griefed

tiulpin commented 2 years ago

.Get well soon! Thank you.