Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins build using variable ${GIT_BRANCH} as sonarqube parameter without "origin/"

Large team with separate git branches per team and sonar as a code quality checker.

The scm tool is set up to pick up every branch that corresponds to this name: 'feature-branch-*' which works perfectly, for the maven build.
I wanted to set up sonarqube so it would use a different branch for every actual git branch, but sonarqube does not allow wildcards. It does however allow variables so I tried ${GIT_BRANCH}, but this variable holds: 'origin/feature-branch-214', which sonarqube does not recognise as a valid branch name. Sonarqube expects 'feature-branch-214'

So I need something to put there (in sonarqube branch) that does a substring of the ${GIT_BRANCH} to exclude the 'origin/' part.

like image 667
Jonas Avatar asked Feb 21 '14 14:02

Jonas


1 Answers

Or you could:

echo NEW_VAR=${GIT_BRANCH#*/} > newfile
like image 86
Dušan Avatar answered Sep 25 '22 15:09

Dušan