gabrie-allaigre / sonar-gitlab-plugin

Add to each commit GitLab in a global commentary on the new anomalies added by this commit and add comment lines of modified files
GNU Lesser General Public License v3.0
713 stars 207 forks source link

Gradle project GitlabCI #130

Open stosik opened 6 years ago

stosik commented 6 years ago

Hey, I'm trying to setup project with sonarqube gradle plugin and GItlabCI. I did following things to make it working:

image: docker.gft.com/tools/docker-build:latest

stages:
  - sonarqube_master_job
  - sonarqube_preview_feature_job

sonarqube_master_job:
  stage: test
  only:
    - master
  script:
    - ./gradlew sonarqube -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN

sonarqube_preview_feature_job:
  stage: test
  only:
    - feature
  script:
    - git checkout origin/master
    - git merge $CI_COMMIT_REF --no-commit --no-ff
    - ./gradlew sonarqube -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN -Dsonar.analysis.mode=preview -Dsonar.gitlab.commit_sha=$CI_COMMIT_REF -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.gitlab.project_id=$CI_PROJECT_ID

Added to project : apply plugin: 'org.sonarqube'

and classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.3'

but once I run the pipeline I get following error:

$ ./gradlew sonarqube -Dsonar.host.url=$SONAR_URL 
-Dsonar.login=$SONAR_LOGIN
env: can't execute 'bash': No such file or directory
ERROR: Job failed: exit code 127

Could it be due to using docker image which has not installed gradle layer ? What potentially image I could use to make it working ? Thanks for any advice.

sesigl commented 6 years ago

looks like it requires bash ? alpine based images have only sh on board :).

try this one:

image: buildpack-deps:sid-scm