Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
qodana: jetbrains/qodana@2024.3.4
Use qodana
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Scan the project with Qodana.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
version: '2.1'
orbs:
qodana: jetbrains/qodana@2024.3.4
jobs:
code-quality:
machine:
image: ubuntu-2004:current
steps:
- checkout
- qodana/scan
workflows:
main:
jobs:
- code-quality:
context: qodana
Scan a project with Qodana. It runs Qodana `scan` command and reports the results. Note that most options can be configured via qodana.yaml (https://www.jetbrains.com/help/qodana/qodana-yaml.html) file. To send reports from CircleCI to Qodana Cloud, all you need to do is to set `QODANA_TOKEN` environment variable in your project settings. To learn more, see https://www.jetbrains.com/help/qodana/circleci.html
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
additional-cache-key | Allows customizing the additional cache hash. Optional.
| No | qodana-2024.3-<< pipeline.git.branch >> | string |
args | Additional Qodana CLI `scan` command arguments (https://github.com/jetbrains/qodana-cli#scan). Optional.
| No | '' | string |
artifact-name | Specify Qodana results artifact name, used for results uploading. Optional.
| No | qodana-report | string |
cache-dir | Directory to store Qodana caches. Optional.
| No | /tmp/cache/qodana | string |
primary-cache-key | Allows customizing the primary cache hash. Optional.
| No | qodana-2024.3-<< pipeline.git.branch >>-<< pipeline.git.revision >> | string |
results-dir | Directory to store the analysis results. Optional.
| No | /tmp/qodana/results | string |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
⚙️ Scan your Java, Kotlin, PHP, Python, JavaScript, TypeScript projects at CircleCI with Qodana
display:
home_url: https://www.jetbrains.com/help/qodana/circleci.html
source_url: https://github.com/JetBrains/qodana-action
commands:
scan:
description: |
Scan a project with Qodana. It runs Qodana `scan` command and reports the results. Note that most options can be configured via qodana.yaml (https://www.jetbrains.com/help/qodana/qodana-yaml.html) file. To send reports from CircleCI to Qodana Cloud, all you need to do is to set `QODANA_TOKEN` environment variable in your project settings. To learn more, see https://www.jetbrains.com/help/qodana/circleci.html
parameters:
additional-cache-key:
default: qodana-2024.3-<< pipeline.git.branch >>
description: |
Allows customizing the additional cache hash. Optional.
type: string
args:
default: ""
description: |
Additional Qodana CLI `scan` command arguments (https://github.com/jetbrains/qodana-cli#scan). Optional.
type: string
artifact-name:
default: qodana-report
description: |
Specify Qodana results artifact name, used for results uploading. Optional.
type: string
cache-dir:
default: /tmp/cache/qodana
description: |
Directory to store Qodana caches. Optional.
type: string
primary-cache-key:
default: qodana-2024.3-<< pipeline.git.branch >>-<< pipeline.git.revision >>
description: |
Allows customizing the primary cache hash. Optional.
type: string
results-dir:
default: /tmp/qodana/results
description: |
Directory to store the analysis results. Optional.
type: string
steps:
- restore_cache:
keys:
- << parameters.primary-cache-key >>
- << parameters.additional-cache-key >>
- run:
command: |
set -e
QODANA_SHA_256=bc81fe9d454ef5e26bc8171082b77c729823409f55d328c18371bee1397ec2cd
CLI_DIRECTORY=/tmp/cache/qodana-cli/2024.3.4
mkdir -p $CLI_DIRECTORY
if [[ ! -x "$CLI_DIRECTORY/qodana" ]]; then
curl -fsSL https://jb.gg/qodana-cli/install | bash -s -- \
v2024.3.4 $CLI_DIRECTORY \
1> /dev/null
fi
echo "$QODANA_SHA_256 $CLI_DIRECTORY/qodana" | sha256sum -c
NONINTERACTIVE=1 $CLI_DIRECTORY/qodana scan \
--cache-dir << parameters.cache-dir >> \
-o << parameters.results-dir >> \
<< parameters.args >>
name: Qodana Scan
- store_artifacts:
destination: << parameters.artifact-name >>
path: << parameters.results-dir >>
- save_cache:
key: << parameters.primary-cache-key >>
paths:
- << parameters.cache-dir >>
- /tmp/cache/qodana-cli/
examples:
scan:
description: |
Scan the project with Qodana.
usage:
version: "2.1"
orbs:
qodana: jetbrains/qodana@2024.3.4
jobs:
code-quality:
machine:
image: ubuntu-2004:current
steps:
- checkout
- qodana/scan
workflows:
main:
jobs:
- code-quality:
context: qodana