Expand Environment variables in SonarQube Scanner for Jenkins


(Bas) #1

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:

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?

(Colin Mueller) #3


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


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!)


(Bas) #4

that is on linux… but i have a windows buildserver

(Julien Henry) #6


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