diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 20469e659d8e01a93f92169ad88af0fff0d1cb64..6693dd94ced8dae44d7add5590164b33e35becfe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,10 +5,7 @@ stages: - deploy SonarScanner Analysis: - image: - name: addianto/sonar-scanner-cli:latest - entrypoint: - - "/bin/bash" + image: addianto/sonar-scanner-cli:latest stage: test script: - sonar-scanner @@ -30,4 +27,4 @@ Publish to Docker Hub: tags: - docker only: - - master + - master \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 98c25eaf4b3c2a62c8c1ca96e021082deebfbcbe..5c31d06ed9ed5a1a23a8cce24c21918409f83bf4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,8 +43,7 @@ ENV DEBIAN_FRONTEND='' ## the value of USERNAME above USER sonar WORKDIR /home/sonar/workspace - -ENTRYPOINT ["sonar-scanner"] +CMD ["sonar-scanner"] # Container image metadata ## Note to editors: metadata values for `created`, `version`, and `revision` diff --git a/README.md b/README.md index 258a999baa2791c3966b9d35bd160f5974c39c56..35b1c4bbb500e9f7fc256bf076dab454b7b398f5 100644 --- a/README.md +++ b/README.md @@ -13,26 +13,25 @@ into SonarScanner via CLI prompt. To run the container image locally using Docker: ```bash -docker run -v $(pwd):/home/sonar/workspace addianto/sonar-scanner-cli:latest [sonar-scanner options] +docker run -it -v $(pwd):/home/sonar/workspace addianto/sonar-scanner-cli:latest bash +sonar-scanner [sonar-scanner options] ``` +> Note: The above example creates a local interactive shell within the running +> container where you can invoke `sonar-scanner` with the desired CLI options. + Example: ```bash -docker run -v $(pwd):/home/sonar/workspace addianto/sonar-scanner-cli:latest -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube -Dsonar.login=[REDACTED] +docker run -it -v $(pwd):/home/sonar/workspace addianto/sonar-scanner-cli:latest bash +sonar-scanner -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube -Dsonar.login=[YOUR TOKEN] ``` -> Note: It is also possible to pass all possible SonarScanner's properties -> via CLI options. YMMV. - To use the container image as a base image for a CI job on GitLab CI/CD: ```yaml SonarScanner Analysis: - image: - name: addianto/sonar-scanner-cli:latest - entrypoint: - - "/bin/bash" + image: addianto/sonar-scanner-cli:latest # Ideally you want to run SonarScanner after the test suite has generated # test & coverage report. The following is only an example to run # SonarScanner concurrently with CI job(s) in `test` stage.