Skip to content

Commit

Permalink
Install AEM Quality Rules by name instead of id. Update Read Me link …
Browse files Browse the repository at this point in the history
…to SonarQube 8.9 Community Edition.
  • Loading branch information
by-4x1 committed Jun 20, 2022
1 parent ddf9bc4 commit 44fa30a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ RUN set -eux; \
rm -rf /tmp/openjdk.tar.gz;

#
# SonarQube setup
# SonarQube community setup
#
#
# SonarQube setup with AEM Rules v1.6 jar
Expand Down Expand Up @@ -136,9 +136,9 @@ RUN set -eux; \
chmod -R 777 "${SQ_DATA_DIR}" "${SQ_EXTENSIONS_DIR}" "${SQ_LOGS_DIR}" "${SQ_TEMP_DIR}"; \
apk del --purge build-dependencies;

COPY --chown=sonarqube:sonarqube run.sh sonar.sh ${SONARQUBE_HOME}/bin/
COPY --chown=sonarqube:sonarqube run.sh sonar.sh quality.sh ${SONARQUBE_HOME}/bin/

WORKDIR ${SONARQUBE_HOME}
EXPOSE 9000
ENTRYPOINT ["bin/run.sh"]
ENTRYPOINT ["sh","-c","bin/quality.sh & bin/run.sh"]
CMD ["bin/sonar.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sonarqube-aem

This is a docker image that is identical to the official [sonarqube docker image](https://github.com/SonarSource/docker-sonarqube/blob/abaf14c38297974eb5de295d42e83066ddb84751/7.7-community/Dockerfile) with an added script to install [AEM-Rules-for-SonarQube](https://github.com/Cognifide/AEM-Rules-for-SonarQube) extension.
This is a docker image that is identical to the official [sonarqube docker image](https://github.com/SonarSource/docker-sonarqube/blob/master/8/community/Dockerfile) with an added script to install [AEM-Rules-for-SonarQube](https://github.com/Cognifide/AEM-Rules-for-SonarQube) extension.

## Running

Expand Down
4 changes: 2 additions & 2 deletions build-and-run-container.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

docker build -t "sonarqube-aem" -f "Dockerfile" .
docker run -p 9000:9000 sonarqube-aem
docker build --tag "sonarqube-aem" -f "Dockerfile" .
docker run --publish 9000:9000 sonarqube-aem
23 changes: 15 additions & 8 deletions quality.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

# add curl dependency
apk add --no-cache --virtual quality-dependencies curl;

#########
# Creates Sonar Qube Custom Quality Gate.
#########
Expand All @@ -15,7 +18,7 @@ error () {
printf "\e[1;31m[quality.sh]:: %s ::\e[0m\n" "$*"
}

# wait here untill sonar is up. sleep 5 seconds between checks.
# wait here until sonar is up. sleep 5 seconds between checks.
while [[ "$(curl -s localhost:9000/api/system/status)" != *'"status":"UP"'* ]]; do
info "Waiting for Sonar to be ready.."
sleep 5;
Expand Down Expand Up @@ -64,45 +67,46 @@ create_condition () {

# by default, the newly created gate ID will be 2; Since Sonar Way gate is 1.
gate_id=2
gate_name=aem-gate

info "Creating Quality Gate: aem-gate"
create_gate -d name=aem-gate
create_gate -d name=$gate_name

info "Setting aem-gate as the default Quality Gate."
set_as_default_gate -d id=$gate_id
set_as_default_gate -d name=$gate_name

info "Creating Condition: Code Coverage - 75% required"
create_condition \
-d metric=coverage \
-d gateId=$gate_id \
-d gateName=$gate_name \
-d error=75 \
-d op=LT

info "Creating Condition: Code Smells - A required"
create_condition \
-d metric=code_smells \
-d gateId=$gate_id \
-d gateName=$gate_name \
-d error=1 \
-d op=GT

info "Creating Condition: Maintainability Rating - A required"
create_condition \
-d metric=sqale_rating \
-d gateId=$gate_id \
-d gateName=$gate_name \
-d error=1 \
-d op=GT

info "Creating Condition: Reliability Rating - A required"
create_condition \
-d metric=reliability_rating \
-d gateId=$gate_id \
-d gateName=$gate_name \
-d error=1 \
-d op=GT

info "Creating Condition: Security Rating - A required"
create_condition \
-d metric=security_rating \
-d gateId=$gate_id \
-d gateName=$gate_name \
-d error=1 \
-d op=GT

Expand Down Expand Up @@ -161,4 +165,7 @@ activate_rules \
-d repositories="AEM Rules,Common HTL," \
-d targetKey=$PROFILE_KEY

# clean up curl dependency
apk del --purge quality-dependencies;

info "Quality Profile Creation done!"

0 comments on commit 44fa30a

Please sign in to comment.