Index: ps/trunk/build/arclint/pyrolint/__phutil_library_map__.php =================================================================== --- ps/trunk/build/arclint/pyrolint/__phutil_library_map__.php +++ ps/trunk/build/arclint/pyrolint/__phutil_library_map__.php @@ -10,11 +10,13 @@ '__library_version__' => 2, 'class' => array( 'ESLintLinter' => 'src/ESLintLinter.php', + 'JenkinsRenderer' => 'src/JenkinsRenderer.php', 'LicenceYearLinter' => 'src/LicenceYearLinter.php', ), 'function' => array(), 'xmap' => array( 'ESLintLinter' => 'ArcanistExternalLinter', + 'JenkinsRenderer' => 'ArcanistLintRenderer', 'LicenceYearLinter' => 'ArcanistLinter', ), )); Index: ps/trunk/build/arclint/pyrolint/src/JenkinsRenderer.php =================================================================== --- ps/trunk/build/arclint/pyrolint/src/JenkinsRenderer.php +++ ps/trunk/build/arclint/pyrolint/src/JenkinsRenderer.php @@ -0,0 +1,49 @@ +getMessages(); + $path = $result->getPath(); + $data = explode("\n", $result->getData()); + array_unshift($data, ''); // make the line numbers work as array indices + + foreach ($messages as $message) { + $dictionary = $message->toDictionary(); + $dictionary['context'] = implode("\n", array_slice( + $data, + max(1, $message->getLine() - self::LINES_OF_CONTEXT), + self::LINES_OF_CONTEXT * 2 + 1)); + $dictionary['path'] = $path; + $this->writeOut(json_encode(json_decode(json_encode($dictionary)))."\n"); + } + } +} Index: ps/trunk/build/jenkins/pipelines/docker-differential.Jenkinsfile =================================================================== --- ps/trunk/build/jenkins/pipelines/docker-differential.Jenkinsfile +++ ps/trunk/build/jenkins/pipelines/docker-differential.Jenkinsfile @@ -133,8 +133,8 @@ sh ''' for file in builderr-*.txt ; do if [ -s "$file" ]; then - echo "$file" >> build-errors.txt - cat "$file" >> build-errors.txt + echo "$file" >> build-errors.txt + cat "$file" >> build-errors.txt fi done ''' @@ -147,9 +147,14 @@ steps { script { try { - sh 'arc lint --output json > .phabricator-lint' + // arc lint outputs an empty file on success - unless there is nothing to lint. + // On failure, it'll output the file and a failure error code. + // Explicitly checking for the file presence is thus best to detect the linter did run + sh 'arc lint --output jenkins --outfile .phabricator-lint && touch .phabricator-lint' } catch (e) { - sh 'echo \"{ \\\"name\\\": \\\"error\\\", \\\"severity\\\": \\\"error\\\", \\\"code\\\": \\\"0\\\", \\\"description\\\": \\\"lint could not run\\\" }\" > .phabricator-lint ' + if (!fileExists(".phabricator-lint")) { + sh '''echo '{ "path": "general", code": "Jenkins", "severity": "error", "name": "ci-error", "description": "Error running lint", "bypassChangedLineFiltering": true }' > .phabricator-lint ''' + } } } }