Expand Environment variables in SonarQube Scanner for Jenkins

Hi there,

We are using Jenkins for building our products, but we have more then 90 .NET projects.
We like to use as many as possible variables in the build scripts to keep them more generic.

In the ‘old’ scanner (the non msbuild one) we could use all environment variables
We use stuff like %JOB_NAME% and %GIT_VERSION% environment variables

Our analysis properties looked like this:
sonar.projectKey=myProject:%JOB_NAME:~0,-10%
sonar.projectName=%JOB_NAME:~0,-10%
sonar.projectVersion=%GIT_COMMIT%

But since we need to move to the new style of running sonarscanner (the msbuild version) we have the 3 fields (key, name and version) we need to set in a separate field. Those fields don’t expand environment variables.

So, the question is simple: can we expand the environment variables for alle fields?

Bas,

You should be able to use this format of using environment variables

${JOB_NAME}

I tested this in a Jenkins job just now.

(I am moving this topic to “Get Help”, but feel free to chime in if you disagree with this!)

Colin

that is on linux… but i have a windows buildserver

Hi,

I haven’t tested, but the code is there to evaluate env variables, and it should not depend on the OS, since it is a Jenkins level env expension:

You should use Jenkins syntax, which is $XXX