I am trying to use the Jenkins plugin. I have this statement that I want to use in either the “Analysis properties” or the sonar-project.properties file.
If ghprbTargetBranch exist then set and use sonar.pullrequest.branch, sonar.pullrequest.base, sonar.pullrequest.key but it does not work. All 4 end up in the CLI parameters.
if [ ${ghprbTargetBranch} != "" ]
then
sonar.pullrequest.branch=${GIT_BRANCH}
sonar.pullrequest.base=origin/${ghprbTargetBranch}
sonar.pullrequest.key=${ghprbPullId}
fi
if [ ${ghprbTargetBranch} == "" ]
then
sonar.branch.name=${GIT_BRANCH}
fi
also, I used this approach, and this time it was just showing SONAR_BRANCH, and SONAR_TARGET as a word, not value.
if [ ${env.BRANCH_NAME} != "master" ]
then
SONAR_BRANCH=${env.BRANCH_NAME}
SONAR_TARGET=master
else
SONAR_BRANCH=${env.BRANCH_NAME}
SONAR_TARGET=
fi
sonar.branch.name=${SONAR_BRANCH}
sonar.branch.target= ${SONAR_TARGET}
How can I use the If statement either in the “Analysis properties” or the sonar-project.properties file.