cds icon indicating copy to clipboard operation
cds copied to clipboard

Sonar Platform

Open yesnault opened this issue 5 years ago • 0 comments

two way:

  • a platform "test" named sonar, containing url, user, password. This platform should be public for an internal CDS
  • an action "Sonar", using this platform.

Old way - a new action CDS_Sonar

steps:

script: # Sonar installation
    - mkdir -p {{.workspace}}/opt
    - apt-get -y update && apt-get -y install unzip
    - cd {{.workspace}}/opt && wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.0.3.778-linux.zip
    - cd {{.workspace}}/opt && unzip sonar-scanner-cli-3.0.3.778-linux.zip
    - ln -s {{.workspace}}/opt/sonar-scanner-3.0.3.778-linux /opt/sonar
    - export PATH="${PATH}:{{.workspace}}/opt/sonar/bin"
  - optional: true
    script:
    - cd '{{.workspace}}'
    - cat <<EOF > sonar-project.properties
    - {{.sonar-project.properties}}
    - EOF
  - optional: true
    script: # Sonar execution
    - cd '{{.workspace}}'
    - export PATH="${PATH}:{{.workspace}}/opt/sonar/bin"
    - export SONAR_SCANNER_OPTS="-Xmx1024m"
    - sonar-scanner -Dsonar.host.url={{.sonarURL}} -Dsonar.login={{.sonarUsername}} -Dsonar.password='{{.sonarPassword}}' -Dsonar.branch='{{.gitBranch}}' -Dsonar.scm.disabled=true

with one parameter named "sonar-project.properties" type text, containing de default value:

sonar.projectKey={{.cds.application}}
sonar.projectName={{.cds.application}}
sonar.sources=.
sonar.exclusions=**/*_test.go,**/vendor/**
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.test.exclusions=**/vendor/**
  • sonarUsername (default: cds.proj.sonarUsername)
  • sonarPassword (default: cds.proj.sonarPassword)
  • gitBranch (default: .git.branch)
  • workspace (default : .cds.workspace) as advanced parameter

allow user to add a worker model pre-requisite replace wget with curl use an advanced parameter for sonar version 3.0.3.778

I prefer the Platform, this let user to use Sonar action without any extra configuration (url, user, password...)

yesnault avatar Oct 02 '18 15:10 yesnault

no need anymore, sonar can be integrated in another way (as a 'companion' who manage vcs event and trigger a cds workflow to run sonar).

yesnault avatar Sep 19 '22 08:09 yesnault