Pass CI branch parameter to build scan

See gh-19658
pull/19789/head
dreis2211 5 years ago committed by Stephane Nicoll
parent 33e414fcb2
commit 240f2fb2c8

@ -210,6 +210,7 @@ jobs:
image: spring-boot-ci-image image: spring-boot-ci-image
file: git-repo/ci/tasks/build-project.yml file: git-repo/ci/tasks/build-project.yml
params: params:
BRANCH: ((branch))
GRADLE_ENTERPRISE_ACCESS_KEY: ((gradle_enterprise_secret_access_key)) GRADLE_ENTERPRISE_ACCESS_KEY: ((gradle_enterprise_secret_access_key))
GRADLE_ENTERPRISE_CACHE_USER: ((gradle_enterprise_cache_user.username)) GRADLE_ENTERPRISE_CACHE_USER: ((gradle_enterprise_cache_user.username))
GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle_enterprise_cache_user.password)) GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle_enterprise_cache_user.password))
@ -299,6 +300,7 @@ jobs:
image: spring-boot-jdk11-ci-image image: spring-boot-jdk11-ci-image
file: git-repo/ci/tasks/build-project.yml file: git-repo/ci/tasks/build-project.yml
params: params:
BRANCH: ((branch))
GRADLE_ENTERPRISE_ACCESS_KEY: ((gradle_enterprise_secret_access_key)) GRADLE_ENTERPRISE_ACCESS_KEY: ((gradle_enterprise_secret_access_key))
GRADLE_ENTERPRISE_CACHE_USER: ((gradle_enterprise_cache_user.username)) GRADLE_ENTERPRISE_CACHE_USER: ((gradle_enterprise_cache_user.username))
GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle_enterprise_cache_user.password)) GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle_enterprise_cache_user.password))
@ -336,6 +338,7 @@ jobs:
image: spring-boot-jdk13-ci-image image: spring-boot-jdk13-ci-image
file: git-repo/ci/tasks/build-project.yml file: git-repo/ci/tasks/build-project.yml
params: params:
BRANCH: ((branch))
GRADLE_ENTERPRISE_ACCESS_KEY: ((gradle_enterprise_secret_access_key)) GRADLE_ENTERPRISE_ACCESS_KEY: ((gradle_enterprise_secret_access_key))
GRADLE_ENTERPRISE_CACHE_USER: ((gradle_enterprise_cache_user.username)) GRADLE_ENTERPRISE_CACHE_USER: ((gradle_enterprise_cache_user.username))
GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle_enterprise_cache_user.password)) GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle_enterprise_cache_user.password))

@ -9,6 +9,7 @@ caches:
- path: gradle - path: gradle
- path: embedmongo - path: embedmongo
params: params:
BRANCH:
CI: true CI: true
GRADLE_ENTERPRISE_ACCESS_KEY: GRADLE_ENTERPRISE_ACCESS_KEY:
GRADLE_ENTERPRISE_CACHE_USERNAME: GRADLE_ENTERPRISE_CACHE_USERNAME:

@ -27,7 +27,7 @@ void tagCiOrLocal() {
void addGitMetadata() { void addGitMetadata() {
gradleEnterprise.buildScan.background { gradleEnterprise.buildScan.background {
def gitCommitId = execAndGetStdout('git', 'rev-parse', '--short=8', '--verify', 'HEAD') def gitCommitId = execAndGetStdout('git', 'rev-parse', '--short=8', '--verify', 'HEAD')
def gitBranchName = execAndGetStdout('git', 'rev-parse', '--abbrev-ref', 'HEAD') def gitBranchName = getBranch()
def gitStatus = execAndGetStdout('git', 'status', '--porcelain') def gitStatus = execAndGetStdout('git', 'status', '--porcelain')
if(gitCommitId) { if(gitCommitId) {
@ -50,6 +50,14 @@ boolean isCi() {
System.getenv('CI') System.getenv('CI')
} }
String getBranch() {
def branch = System.getenv('BRANCH')
if (branch != null && !branch.isEmpty()) {
return branch
}
return execAndGetStdout('git', 'rev-parse', '--abbrev-ref', 'HEAD')
}
String execAndGetStdout(String... args) { String execAndGetStdout(String... args) {
def stdout = new ByteArrayOutputStream() def stdout = new ByteArrayOutputStream()
exec { exec {

Loading…
Cancel
Save