Skip to content

Commit df4de6b

Browse files
authored
Update SonarQube Community Server and CLI scanner version (#26)
* Upgrade Docker to 25.5 and change passwd * update CLI version to 11.3 * test last release * using branch name to run latest action code * rename actions * Change password
1 parent 8130e1f commit df4de6b

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,28 @@ jobs:
8282
ISSUES=$(cat ./blahblah.json | jq -r '.component.measures[] | select(.metric == "open_issues").value')
8383
echo "# of issues = ${ISSUES}"
8484
[ "${ISSUES}" -le 3 ]
85+
86+
sonarless-action-test-on-main:
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v4
91+
92+
- name: Sonarless Scan
93+
uses: gitricko/sonarless@main
94+
with:
95+
sonar-source-path: '.'
96+
sonar-metrics-path: './blahblah.json'
97+
sonar-instance-port: '9999'
98+
99+
- name: Check Sonar Metrics
100+
run: |
101+
echo "Checking for 0 vulnerabilities in Sonar Metrics JSON"
102+
VULN=$(cat ./blahblah.json | jq -r '.component.measures[] | select(.metric == "vulnerabilities").value')
103+
echo "# of vulnerabilities = ${VULN}"
104+
[ "${VULN}" -eq "0" ]
105+
106+
echo "Checking for any issues <= 3 in Sonar Metrics JSON"
107+
ISSUES=$(cat ./blahblah.json | jq -r '.component.measures[] | select(.metric == "open_issues").value')
108+
echo "# of issues = ${ISSUES}"
109+
[ "${ISSUES}" -le 3 ]

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![GitHub Release](https://img.shields.io/github/v/release/gitricko/sonarless)
55
![GitHub commits since latest release](https://img.shields.io/github/commits-since/gitricko/sonarless/latest)
66

7-
# Sonarless v1.2
7+
# Sonarless v1.3
88

99
This developer-friendly CLI and GitHub Action enable SonarQube scanning for your repository without the need for a dedicated hosted SonarQube server. It starts a SonarQube Docker instance, allowing developers to scan code, check results, and generate a JSON metrics file for automation. This ensures you can easily assess and maintain the quality of your code.
1010

@@ -49,7 +49,7 @@ Enjoy!!!
4949
To understand CLI sub-commands, just run `sonarless help`
5050

5151
Usually, you only need to know 2 sub-commands
52-
- `sonarless scan`: to start scanning your code in the current directory will be uploaded for scanning. When the scan is done, just login webui into your local personal instance of sonarqube via [http://localhost:9234](http://localhost:9234) to get details from SonarQube. The default password for `admin` is `sonarless`
52+
- `sonarless scan`: to start scanning your code in the current directory will be uploaded for scanning. When the scan is done, just login webui into your local personal instance of sonarqube via [http://localhost:9234](http://localhost:9234) to get details from SonarQube. The default password for `admin` is `Son@rless123`
5353

5454
- `sonarless results`: to generate `sonar-metrics.json` metrics file in your current directory
5555

@@ -62,7 +62,7 @@ This CLI works perfectly with Github CodeSpace
6262

6363
<!-- start usage -->
6464
```yaml
65-
- uses: gitricko/sonarless@v1.2
65+
- uses: gitricko/sonarless@v1.3
6666
with:
6767
# Folder path to scan from git-root
6868
# Default: .
@@ -100,7 +100,7 @@ jobs:
100100
uses: actions/checkout@v4
101101

102102
- name: Sonarless Scan
103-
uses: gitricko/sonarless@v1.2
103+
uses: gitricko/sonarless@v1.3
104104
```
105105
106106
## Scan particular folder from git root directory
@@ -114,7 +114,7 @@ jobs:
114114
uses: actions/checkout@v4
115115

116116
- name: Sonarless Scan
117-
uses: gitricko/sonarless@v1.2
117+
uses: gitricko/sonarless@v1.3
118118
with:
119119
sonar-source-path: 'src'
120120
```
@@ -130,7 +130,7 @@ jobs:
130130
uses: actions/checkout@v4
131131

132132
- name: Sonarless Scan
133-
uses: gitricko/sonarless@v1.2
133+
uses: gitricko/sonarless@v1.3
134134
with:
135135
sonar-source-path: 'src'
136136
sonar-metrics-path: './sonar-mymetrics.json'
@@ -154,7 +154,7 @@ jobs:
154154
uses: actions/checkout@v4
155155
156156
- name: Sonarless Scan
157-
uses: gitricko/sonarless@v1.2
157+
uses: gitricko/sonarless@v1.3
158158
with:
159159
sonar-instance-port: '1234'
160160
```

makefile.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export SONAR_SOURCE_PATH=${SONAR_SOURCE_PATH:-"."}
99
export SONAR_METRICS_PATH=${SONAR_METRICS_PATH:-"./sonar-metrics.json"}
1010
export SONAR_EXTENSION_DIR="${HOME}/.sonarless/extensions"
1111

12-
export DOCKER_SONAR_CLI=${DOCKER_SONAR_CLI:-"sonarsource/sonar-scanner-cli:10.0"}
13-
export DOCKER_SONAR_SERVER=${DOCKER_SONAR_SERVER:-"sonarqube:10.6-community"}
12+
export DOCKER_SONAR_CLI=${DOCKER_SONAR_CLI:-"sonarsource/sonar-scanner-cli:11.3"}
13+
export DOCKER_SONAR_SERVER=${DOCKER_SONAR_SERVER:-"sonarqube:25.5.0.107428-community"}
1414

1515
export CLI_NAME="sonarless"
1616

@@ -91,13 +91,13 @@ function start() {
9191
exit 1
9292
fi
9393

94-
# 2. Reset admin password to sonarless
94+
# 2. Reset admin password to sonarless123
9595
curl -s -X POST -u "admin:admin" \
96-
-d "login=admin&previousPassword=admin&password=sonarless" \
96+
-d "login=admin&previousPassword=admin&password=Son@rless123" \
9797
"http://localhost:${SONAR_INSTANCE_PORT}/api/users/change_password"
9898
echo "Local sonarqube URI: http://localhost:${SONAR_INSTANCE_PORT}"
9999

100-
echo "Credentials: admin/sonarless"
100+
echo "Credentials: admin/Son@rless123"
101101

102102
}
103103

@@ -109,14 +109,14 @@ function scan() {
109109
start
110110

111111
# 1. Create default project and set default fav
112-
curl -s -u "admin:sonarless" -X POST "http://localhost:${SONAR_INSTANCE_PORT}/api/projects/create?name=${SONAR_PROJECT_NAME}&project=${SONAR_PROJECT_NAME}" | jq
113-
curl -s -u "admin:sonarless" -X POST "http://localhost:${SONAR_INSTANCE_PORT}/api/users/set_homepage?type=PROJECT&component=${SONAR_PROJECT_NAME}"
112+
curl -s -u "admin:Son@rless123" -X POST "http://localhost:${SONAR_INSTANCE_PORT}/api/projects/create?name=${SONAR_PROJECT_NAME}&project=${SONAR_PROJECT_NAME}" | jq
113+
curl -s -u "admin:Son@rless123" -X POST "http://localhost:${SONAR_INSTANCE_PORT}/api/users/set_homepage?type=PROJECT&component=${SONAR_PROJECT_NAME}"
114114

115115
echo "SONAR_GITROOT: ${SONAR_GITROOT}"
116116
echo "SONAR_SOURCE_PATH: ${SONAR_SOURCE_PATH}"
117117

118118
# 2. Create token and scan using internal-ip becos of docker to docker communication
119-
SONAR_TOKEN=$(curl -s -X POST -u "admin:sonarless" "http://localhost:${SONAR_INSTANCE_PORT}/api/user_tokens/generate?name=$(date +%s%N)" | jq -r .token)
119+
SONAR_TOKEN=$(curl -s -X POST -u "admin:Son@rless123" "http://localhost:${SONAR_INSTANCE_PORT}/api/user_tokens/generate?name=$(date +%s%N)" | jq -r .token)
120120
export SONAR_TOKEN
121121

122122
docker run --rm --network "${CLI_NAME}" \
@@ -133,7 +133,7 @@ function scan() {
133133
for _ in $(seq 1 120); do
134134
sleep 1
135135
printf .
136-
status_value=$(curl -s -u "admin:sonarless" "http://localhost:${SONAR_INSTANCE_PORT}/api/qualitygates/project_status?projectKey=${SONAR_PROJECT_NAME}" | jq -r .projectStatus.status)
136+
status_value=$(curl -s -u "admin:Son@rless123" "http://localhost:${SONAR_INSTANCE_PORT}/api/qualitygates/project_status?projectKey=${SONAR_PROJECT_NAME}" | jq -r .projectStatus.status)
137137
# Checking if the status value is not "NONE"
138138
if [[ "$status_value" != "NONE" ]]; then
139139
echo
@@ -149,7 +149,7 @@ function scan() {
149149

150150
function results() {
151151
# use this params to collect stats
152-
curl -s -u "admin:sonarless" "http://localhost:${SONAR_INSTANCE_PORT}/api/measures/component?component=${SONAR_PROJECT_NAME}&metricKeys=bugs,vulnerabilities,code_smells,quality_gate_details,violations,duplicated_lines_density,ncloc,coverage,reliability_rating,security_rating,security_review_rating,sqale_rating,security_hotspots,open_issues" \
152+
curl -s -u "admin:Son@rless123" "http://localhost:${SONAR_INSTANCE_PORT}/api/measures/component?component=${SONAR_PROJECT_NAME}&metricKeys=bugs,vulnerabilities,code_smells,quality_gate_details,violations,duplicated_lines_density,ncloc,coverage,reliability_rating,security_rating,security_review_rating,sqale_rating,security_hotspots,open_issues" \
153153
| jq -r > "${SONAR_GITROOT}/${SONAR_METRICS_PATH}"
154154
cat "${SONAR_GITROOT}/${SONAR_METRICS_PATH}"
155155
echo "Scan results written to ${SONAR_GITROOT}/${SONAR_METRICS_PATH}"

0 commit comments

Comments
 (0)