diff --git a/Jenkins/Phabricator-pipeline/Jenkinsfile b/Jenkins/Phabricator-pipeline/Jenkinsfile index c32bf86..efd78e5 100644 --- a/Jenkins/Phabricator-pipeline/Jenkinsfile +++ b/Jenkins/Phabricator-pipeline/Jenkinsfile @@ -13,6 +13,7 @@ // limitations under the License. def success = true +def failure_message = "" pipeline { agent { label 'linux' } @@ -72,15 +73,23 @@ pipeline { } stage('arc patch'){ steps { + success = false + failure_message = "Failed to apply patch" sh "${SCRIPT_DIR}/phabtalk/apply_patch2.py ${DIFF_ID} --token ${CONDUIT_TOKEN} --url ${PHABRICATOR_HOST} --comment-file ${PHAB_LOG}" + success = true + failure_message = "" } } stage('CMake') { steps { + success = false + failure_message = "Failed to run cmake" sh 'rm -rf build || true' sh 'mkdir -p build' sh 'mkdir -p "${TARGET_DIR}"' sh "${SCRIPT_DIR}/run_cmake.sh" + success = true + failure_message = "" } } stage('ninja all') { @@ -90,6 +99,7 @@ pipeline { sh(script: "${SCRIPT_DIR}/run_ninja.sh all") } catch (e) { success = false; + failure_message = "'ninja all' failed" // append as build might already be broken echo e.toString() } } @@ -116,6 +126,7 @@ pipeline { sh(script: "${SCRIPT_DIR}/run_ninja.sh check-all") } catch (e) { success = false; + failure_message += "\n'ninja check-all' failed" // append as build might already be broken echo e.toString() } } @@ -123,7 +134,15 @@ pipeline { } stage('linters') { steps { - sh "${SCRIPT_DIR}/lint.sh" + script { + try { + sh(script: "${SCRIPT_DIR}/lint.sh") + } catch (e) { + success = false; + failure_message += "\nFailed to run linters" // append as build might already be broken + echo e.toString() + } + } } } } @@ -160,7 +179,8 @@ pipeline { --clang-tidy-result "clang-tidy.txt" \ --clang-tidy-ignore "${SCRIPT_DIR}/clang-tidy-comments.ignore" \ --results-dir "${TARGET_DIR}" \ - --results-url "${RESULT_URL}" + --results-url "${RESULT_URL}" \ + --failures "${failure_message}" """ } } diff --git a/scripts/phabtalk/phabtalk.py b/scripts/phabtalk/phabtalk.py index 374f712..4226adb 100755 --- a/scripts/phabtalk/phabtalk.py +++ b/scripts/phabtalk/phabtalk.py @@ -191,6 +191,7 @@ class BuildReport: self.results_dir = args.results_dir # type: str self.results_url = args.results_url # type: str self.workspace = args.workspace # type: str + self.failure_messages = args.failures # type: str self.api = PhabTalk(args.conduit_token, args.host, args.dryrun) @@ -237,7 +238,13 @@ class BuildReport: '=&title=enable%20checks%20for%20{{PATH}}">enable it for your project'.format( urllib.parse.quote(title))) with open(os.path.join(self.results_dir, 'summary.html'), 'w') as f: - f.write('') + f.write('') + 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) @@ -456,6 +463,7 @@ def main(): dest='results_url', 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") args = parser.parse_args() reporter = BuildReport(args)