You can create a new variable and assign a value:
`echo ${GIT_BRANCH} | cut -d'/' -f 2-`
You can then use the new variable in the Jankins Git Branch SonarQube parameter by following these steps.
Steps
In the build section, add the Execute Shell step with command :
echo NEW_VAR=`echo ${GIT_BRANCH} | cut -d'/' -f 2-` > newfile
Then add the Inject an environment variable step with Properties File Path :
newfile
In the SonarQube configuration, leave the branch empty field and add the following to Additional properties field :
-Dsonar.branch=${NEW_VAR}
The above solution is not very clean, but I checked that it works
source share