feat: sonar-node-plugin - sonar-scanner based on node:lts-alpine

This commit is contained in:
kytay
2022-10-29 14:10:47 +00:00
parent 90fad4305f
commit 052e530ef9
2 changed files with 47 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
FROM node:lts-alpine
ENV SONAR_VERSION=4.7.0.2747
ENV SONAR_SCANNER_CLI=sonar-scanner-cli-${SONAR_VERSION}
ENV SONAR_SCANNER=sonar-scanner-${SONAR_VERSION}
RUN apk add bash curl openjdk11-jre-headless
RUN curl https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/${SONAR_SCANNER_CLI}.zip -so /opt/${SONAR_SCANNER_CLI}.zip && \
unzip -d /opt /opt/${SONAR_SCANNER_CLI}.zip && \
rm /opt/${SONAR_SCANNER_CLI}.zip
COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
RUN chmod +x /usr/bin/docker-entrypoint.sh
ENV PATH=$PATH:/opt/${SONAR_SCANNER}/bin
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
JAVA_OPTS=""
if [[ -n "PLUGIN_SONAR_HOST" ]]; then
JAVA_OPTS+=" -Dsonar.host.url=${PLUGIN_SONAR_HOST}"
fi
if [[ -n "PLUGIN_SONAR_TOKEN" ]]; then
JAVA_OPTS+=" -Dsonar.login=${PLUGIN_SONAR_TOKEN}"
elif [[ -n "PLUGIN_SONAR_LOGIN" && -n "PLUGIN_SONAR_PASSWORD" ]]; then
JAVA_OPTS+=" -Dsonar.login=${PLUGIN_SONAR_LOGIN} -Dsonar.password=${PLUGIN_SONAR_PASSWORD}"
echo "Using authentication token is encouraged for security reasons. Refer to https://docs.sonarqube.org/latest/user-guide/user-token/"
fi
if [[ -n "PLUGIN_SONAR_LOGLEVEL" ]]; then
JAVA_OPTS+=" -Dsonar.log.level=${PLUGIN_SONAR_LOGLEVEL}"
fi
if [[ -n "PLUGIN_SONAR_PROJECT_SETTINGS" ]]; then
JAVA_OPTS+=" -Dproject.settings=${PLUGIN_SONAR_PROJECT_SETTINGS}"
fi
if [[ -n "PLUGIN_SONAR_DEBUG" && ${PLUGIN_SONAR_DEBUG} == "true" ]]; then
JAVA_OPTS+=" -X"
fi
sonar-scanner ${JAVA_OPTS}