diff --git a/Dockerfile b/Dockerfile index 6e1c225..411c830 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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"] diff --git a/README.md b/README.md index 3198d96..35ae1e7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build-and-run-container.sh b/build-and-run-container.sh index 4c24a5f..c4b3206 100755 --- a/build-and-run-container.sh +++ b/build-and-run-container.sh @@ -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 diff --git a/quality.sh b/quality.sh index 0b90a3a..d6c9e5a 100755 --- a/quality.sh +++ b/quality.sh @@ -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. ######### @@ -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; @@ -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 @@ -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!" \ No newline at end of file