From 70df407e0e879af4f7bd67f4629c9ea0b7313bf4 Mon Sep 17 00:00:00 2001 From: Mikhail Goncharov Date: Wed, 19 Feb 2020 16:49:39 +0100 Subject: [PATCH] Add name of build agent to summary --- Jenkins/Phabricator-pipeline/Jenkinsfile | 3 ++- .../Phabricator-windows-pipeline/Jenkinsfile | 3 ++- scripts/phabtalk/phabtalk.py | 17 +++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Jenkins/Phabricator-pipeline/Jenkinsfile b/Jenkins/Phabricator-pipeline/Jenkinsfile index efb4694..42c3a14 100644 --- a/Jenkins/Phabricator-pipeline/Jenkinsfile +++ b/Jenkins/Phabricator-pipeline/Jenkinsfile @@ -174,7 +174,8 @@ pipeline { --clang-tidy-ignore "${SCRIPT_DIR}/clang-tidy-comments.ignore" \ --results-dir "${TARGET_DIR}" \ --results-url "${RESULT_URL}" \ - --failures "${failure_message}" + --failures "${failure_message}" \ + --name "linux" """ } } diff --git a/Jenkins/Phabricator-windows-pipeline/Jenkinsfile b/Jenkins/Phabricator-windows-pipeline/Jenkinsfile index 0d79d67..89437df 100644 --- a/Jenkins/Phabricator-windows-pipeline/Jenkinsfile +++ b/Jenkins/Phabricator-windows-pipeline/Jenkinsfile @@ -162,7 +162,8 @@ pipeline { --results-dir "${RESULT_DIR}" ^ --results-url "${RESULT_URL}" ^ --failures "${failure_message}" ^ - --buildresult ${currentBuild.result} + --buildresult ${currentBuild.result} ^ + --name "windows" """ dir("${RESULT_DIR}") { // upload results to diff --git a/scripts/phabtalk/phabtalk.py b/scripts/phabtalk/phabtalk.py index 08b8910..80cbb6a 100755 --- a/scripts/phabtalk/phabtalk.py +++ b/scripts/phabtalk/phabtalk.py @@ -124,9 +124,9 @@ class PhabTalk: lint=lint_messages)) def add_artifact(self, phid: str, file: str, name: str, results_url: str): - artifactKey=str(uuid.uuid4()) - artifactType='uri' - artifactData={'uri': '{}/{}'.format(results_url, file), + artifactKey = str(uuid.uuid4()) + artifactType = 'uri' + artifactData = {'uri': '{}/{}'.format(results_url, file), 'ui.external': True, 'name': name} if self.dryrun: @@ -203,9 +203,11 @@ class BuildReport: self.results_url = args.results_url # type: str self.workspace = args.workspace # type: str self.failure_messages = args.failures # type: str + self.name = args.name # type: str self.api = PhabTalk(args.conduit_token, args.host, args.dryrun) + self.revision_id = self.api.get_revision_id(self.diff_id) self.comments = [] self.success = True self.working = False @@ -263,12 +265,14 @@ class BuildReport: '.failure {color:red;}\n' '.success {color:green;}\n' '') + f.write('

Build result for diff {0} {1} at {2}

'.format( + self.revision_id, self.diff_id, self.name)) if self.failure_messages and len(self.failure_messages) > 0: for s in self.failure_messages.split('\n'): f.write('

{}

'.format(s)) f.write('

' + '

'.join(self.comments) + '

') f.write('') - self.api.add_artifact(self.ph_id, 'summary.html', 'summary', self.results_url) + self.api.add_artifact(self.ph_id, 'summary.html', 'summary ' + self.name, self.results_url) def add_clang_format(self): """Populates results from diff produced by clang format.""" @@ -282,7 +286,7 @@ class BuildReport: return p = os.path.join(self.results_dir, self.clang_format_patch) if os.stat(p).st_size != 0: - self.api.add_artifact(self.ph_id, self.clang_format_patch, "clang-format", self.results_url) + self.api.add_artifact(self.ph_id, self.clang_format_patch, 'clang-format ' + self.name, self.results_url) diffs = _parse_patch(open(p, 'r')) success = len(diffs) == 0 for d in diffs: @@ -324,7 +328,7 @@ class BuildReport: return p = os.path.join(self.results_dir, self.clang_tidy_result) if os.stat(p).st_size > 0: - self.api.add_artifact(self.ph_id, self.clang_tidy_result, "clang-tidy", self.results_url) + self.api.add_artifact(self.ph_id, self.clang_tidy_result, 'clang-tidy ' + self.name, self.results_url) ignore = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, open(self.clang_tidy_ignore, 'r').readlines()) for line in open(p, 'r'): @@ -491,6 +495,7 @@ def main(): help="public URL to access results directory") parser.add_argument('--workspace', type=str, required=True, help="path to workspace") parser.add_argument('--failures', type=str, default=None, help="optional failure messages separated by newline") + parser.add_argument('--name', type=str, default='', help="optional name of the build bot") args = parser.parse_args() reporter = BuildReport(args)