From 9aae072872c499b745ae23a2710187b3921da4b3 Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Wed, 8 Apr 2020 17:12:58 -0500 Subject: [PATCH] Add build scan URI to Slack notifications from CI Fixes gh-19703 --- ci/pipeline.yml | 52 +++++++++++++++++++++++++++++++------- ci/tasks/build-project.yml | 1 + settings.gradle | 7 +++++ 3 files changed, 51 insertions(+), 9 deletions(-) diff --git a/ci/pipeline.yml b/ci/pipeline.yml index eba8500fa1..4a78b607ec 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -276,7 +276,11 @@ jobs: params: { state: "failure", commit: "git-repo" } - put: slack-alert params: - text: ":concourse-failed: " + text: > + :concourse-failed: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed! + [] + [<$TEXT_FILE_CONTENT|build scan>] + text_file: git-repo/build/build-scan-uri.txt silent: true icon_emoji: ":concourse:" username: concourse-ci @@ -302,13 +306,19 @@ jobs: do: - put: slack-alert params: - text: ":concourse-failed: " + text: > + :concourse-failed: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed! + [] silent: true icon_emoji: ":concourse:" username: concourse-ci - put: slack-alert params: - text: ":concourse-succeeded: " + text: > + :concourse-succeeded: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} was successful! + [] + [<$TEXT_FILE_CONTENT|build scan>] + text_file: git-repo/build/build-scan-uri.txt silent: true icon_emoji: ":concourse:" username: concourse-ci @@ -366,7 +376,11 @@ jobs: params: { state: "failure", commit: "git-repo" } - put: slack-alert params: - text: ":concourse-failed: " + text: > + :concourse-failed: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed! + [] + [<$TEXT_FILE_CONTENT|build scan>] + text_file: git-repo/build/build-scan-uri.txt silent: true icon_emoji: ":concourse:" username: concourse-ci @@ -374,7 +388,11 @@ jobs: params: { state: "success", commit: "git-repo" } - put: slack-alert params: - text: ":concourse-succeeded: " + text: > + :concourse-succeeded: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} was successful! + [] + [<$TEXT_FILE_CONTENT|build scan>] + text_file: git-repo/build/build-scan-uri.txt silent: true icon_emoji: ":concourse:" username: concourse-ci @@ -404,7 +422,11 @@ jobs: params: { state: "failure", commit: "git-repo" } - put: slack-alert params: - text: ":concourse-failed: " + text: > + :concourse-failed: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed! + [] + [<$TEXT_FILE_CONTENT|build scan>] + text_file: git-repo/build/build-scan-uri.txt silent: true icon_emoji: ":concourse:" username: concourse-ci @@ -412,7 +434,11 @@ jobs: params: { state: "success", commit: "git-repo" } - put: slack-alert params: - text: ":concourse-succeeded: " + text: > + :concourse-succeeded: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} was successful! + [] + [<$TEXT_FILE_CONTENT|build scan>] + text_file: git-repo/build/build-scan-uri.txt silent: true icon_emoji: ":concourse:" username: concourse-ci @@ -439,13 +465,21 @@ jobs: do: - put: slack-alert params: - text: ":concourse-failed: " + text: > + :concourse-failed: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} failed! + [] + [<$TEXT_FILE_CONTENT|build scan>] + text_file: git-repo/build/build-scan-uri.txt silent: true icon_emoji: ":concourse:" username: concourse-ci - put: slack-alert params: - text: ":concourse-succeeded: " + text: > + :concourse-succeeded: ${BUILD_PIPELINE_NAME} ${BUILD_JOB_NAME} was successful! + [] + [<$TEXT_FILE_CONTENT|build scan>] + text_file: git-repo/build/build-scan-uri.txt silent: true icon_emoji: ":concourse:" username: concourse-ci diff --git a/ci/tasks/build-project.yml b/ci/tasks/build-project.yml index e13f5689fb..e6c296c49a 100644 --- a/ci/tasks/build-project.yml +++ b/ci/tasks/build-project.yml @@ -4,6 +4,7 @@ inputs: - name: git-repo outputs: - name: distribution-repository +- name: git-repo caches: - path: gradle - path: embedmongo diff --git a/settings.gradle b/settings.gradle index 6f3421bc14..17a3839242 100644 --- a/settings.gradle +++ b/settings.gradle @@ -34,6 +34,13 @@ settings.gradle.projectsLoaded { if (settings.gradle.rootProject.hasProperty('buildJavaHome')) { value('Build Java home', settings.gradle.rootProject.getProperty('buildJavaHome')) } + + settings.gradle.rootProject.getBuildDir().mkdirs() + new File(settings.gradle.rootProject.getBuildDir(), "build-scan-uri.txt").text = "(build scan not generated)" + + buildScanPublished { scan -> + new File(settings.gradle.rootProject.getBuildDir(), "build-scan-uri.txt").text = "${scan.buildScanUri}\n" + } } } }