Skip to content

Commit 149d909

Browse files
committed
Add SONAR_ORGANIZATION
The SONAR_ORGANIZATION variable has been added to support the use of personal organization for analysis.
1 parent 38ce380 commit 149d909

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.github/workflows/code-analysis-pull.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
types:
77
- completed
88

9+
env:
10+
SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION || github.repository_owner }}
11+
912
jobs:
1013
retrieve-pr:
1114
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
@@ -115,14 +118,16 @@ jobs:
115118
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
116119
restore-keys: ${{ runner.os }}-m2
117120

121+
# https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-maven/
118122
- name: Build and analyze with SonarCloud
119123
env:
120124
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
121125
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
122126
run: >
123127
mvn
124128
-B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
125-
-Dsonar.projectKey=dogtagpki_jss
129+
-Dsonar.organization=${SONAR_ORGANIZATION}
130+
-Dsonar.projectKey=${SONAR_ORGANIZATION}_jss
126131
-pl '!native,!symkey'
127132
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
128133
-Dsonar.pullrequest.key=${{ needs.retrieve-pr.outputs.pr-number }}

.github/workflows/code-analysis.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Code Analysis
22

33
on: [push, pull_request]
44

5+
env:
6+
SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION || github.repository_owner }}
7+
58
jobs:
69
build:
710
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
@@ -38,14 +41,16 @@ jobs:
3841
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
3942
restore-keys: ${{ runner.os }}-m2
4043

44+
# https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-maven/
4145
- name: Build and analyze with SonarCloud
4246
env:
4347
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
4448
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4549
run: >
4650
mvn
4751
-B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
48-
-Dsonar.projectKey=dogtagpki_jss
52+
-Dsonar.organization=${SONAR_ORGANIZATION}
53+
-Dsonar.projectKey=${SONAR_ORGANIZATION}_jss
4954
-pl '!native,!symkey'
5055
5156
get-pr-ref:

pom.xml

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<packaging>pom</packaging>
1111

1212
<properties>
13-
<sonar.organization>dogtagpki</sonar.organization>
1413
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
1514
<sonar.c.file.suffixes>-</sonar.c.file.suffixes>
1615
<sonar.cpp.file.suffixes>-</sonar.cpp.file.suffixes>

0 commit comments

Comments
 (0)