Skip to content

Instantly share code, notes, and snippets.

@nikhuber
Last active March 15, 2019 11:45
Show Gist options
  • Save nikhuber/bd2e35193ec95a576f4f9caf8aead2b1 to your computer and use it in GitHub Desktop.
Save nikhuber/bd2e35193ec95a576f4f9caf8aead2b1 to your computer and use it in GitHub Desktop.
Gitlab CI pipeline definition for sonar scanner
before_script:
- export VERSION="${CI_PROJECT_NAMESPACE}_${CI_BUILD_ID}_$(date "+%Y-%m-%d-%H:%M:%S")"
- export PROJECTROOT=`pwd`
- export DOCKERPROJECTROOT='/srv/example/'
stages:
- test
- analysis
unittests:
stage: test
script:
- phpunit --verbose -c phpunit.xml # Log files are configured in phpunit.xml
artifacts: # Persist the files that we use as input for the analysis step
paths:
- *.xml
when: on_success
sonar:
stage: analysis
dependencies: # Include the log files produced during test stage
- unittests
script:
- docker run --rm --mount type=bind,source=$PROJECTROOT,target=$DOCKERPROJECTROOT --tmpfs $DOCKERPROJECTROOT/.scannerwork -w=$DOCKERPROJECTROOT nikhuber/sonar-scanner:3.0.3.778 sonar-scanner -Dsonar.projectVersion=$VERSION
@JordanProtin
Copy link

Hi Nik,

To begin with, congratulations for this great works !
I try to use your sonar scanner in my CI Pipeline Integration.
And I get this error during pipeline running :

selection_002

And my .gitlab-ci.yml looks like this :
selection_003

Do you have any idea about this issue ?
Thk's

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment