Skip to content

Commit

Permalink
Pass CI branch parameter to build scan
Browse files Browse the repository at this point in the history
  • Loading branch information
dreis2211 committed Jan 12, 2020
1 parent bda3ced commit cf621dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ jobs:
image: spring-boot-ci-image
file: git-repo/ci/tasks/build-project.yml
params:
BRANCH: ((branch))
GRADLE_ENTERPRISE_CACHE_USERNAME: ((gradle-enterprise-cache-username))
GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle-enterprise-cache-password))
on_failure:
Expand Down Expand Up @@ -298,6 +299,7 @@ jobs:
image: spring-boot-jdk11-ci-image
file: git-repo/ci/tasks/build-project.yml
params:
BRANCH: ((branch))
GRADLE_ENTERPRISE_CACHE_USERNAME: ((gradle-enterprise-cache-username))
GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle-enterprise-cache-password))
on_failure:
Expand Down Expand Up @@ -334,6 +336,7 @@ jobs:
image: spring-boot-jdk13-ci-image
file: git-repo/ci/tasks/build-project.yml
params:
BRANCH: ((branch))
GRADLE_ENTERPRISE_CACHE_USERNAME: ((gradle-enterprise-cache-username))
GRADLE_ENTERPRISE_CACHE_PASSWORD: ((gradle-enterprise-cache-password))
on_failure:
Expand Down
1 change: 1 addition & 0 deletions ci/tasks/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ caches:
- path: gradle
- path: embedmongo
params:
BRANCH:
CI: true
GRADLE_ENTERPRISE_CACHE_USERNAME:
GRADLE_ENTERPRISE_CACHE_PASSWORD:
Expand Down
10 changes: 9 additions & 1 deletion gradle/build-scan-user-data.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void tagCiOrLocal() {
void addGitMetadata() {
gradleEnterprise.buildScan.background {
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')

if(gitCommitId) {
Expand All @@ -50,6 +50,14 @@ boolean isCi() {
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) {
def stdout = new ByteArrayOutputStream()
exec {
Expand Down

0 comments on commit cf621dc

Please # to comment.