Hi,
a multibranch jenkins pipeline calls a gradle build.
Need to pass the BRANCH_NAME to the sonarqube task in build.gradle:
sonarqube {
properties {
property “sonar.host.url”, “https://sonar”
property “sonar.projectKey”, “com.foo.bar:Foobar”
property “sonar.projectName”, “com.foo.bar-Foobar”
property “sonar.binaries”, “build”
property “sonar.branch.name”, “${branchname}” <---------------
property “sonar.branch.target”, “master”
}
}
Tried with:
- direct use of ${BRANCH_NAME} in gradle build
- gradlew Dbranchname=${BRANCH_NAME} in Jenkinsfile
- gradlew Pbranchname=${BRANCH_NAME} in Jenkinsfile
- def branchname=${BRANCH_NAME} before calling gradlew in Jenkinsfile
but nothing worked, the property branchname is always unknown.
How to pass a property from Jenkinsfile to gradle build ?
Regards,
Gilbert