phabricator-jenkins-plugin icon indicating copy to clipboard operation
phabricator-jenkins-plugin copied to clipboard

NonDifferentialHarbormasterTask doesn't record Uberalls coverage information

Open maroux opened this issue 7 years ago • 5 comments

We use 2 different jobs for one project - one for DIFF and one for CI. The job for DIFF works fine and records coverage and posts as comment. However, the job for CI doesn't record coverage automatically because it runs NonDifferentialHarbormasterTask which doesn't have uberalls integrated. I think the fix is pretty simple - basically need to copy bits from NonDifferentialBuildTask - thoughts?

This way you don't need a cron job running coverage for master branch - instead it can just rely on the coverage information recorded from the CI build.

maroux avatar Jun 21 '18 21:06 maroux

diff --git a/src/main/java/com/uber/jenkins/phabricator/PhabricatorNotifier.java b/src/main/java/com/uber/jenkins/phabricator/PhabricatorNotifier.java
index 2690414..0c809e7 100644
--- a/src/main/java/com/uber/jenkins/phabricator/PhabricatorNotifier.java
+++ b/src/main/java/com/uber/jenkins/phabricator/PhabricatorNotifier.java
@@ -144,7 +144,7 @@ public class PhabricatorNotifier extends Notifier implements SimpleBuildStep {
         // a Harbormaster build on a commit rather than a differential, but still wants build status.
         // If DIFF_ID is present but PHID is not, it means somebody is doing a Differential build without Harbormaster.
         // So only skip build result processing if both are blank (e.g. master runs to update coverage data)
-        if (CommonUtils.isBlank(phid) && !isDifferential) {
+        if (!isDifferential) {
             if (needsDecoration) {
                 build.addAction(PhabricatorPostbuildAction.createShortText(branch, null));
             }
@@ -165,7 +165,10 @@ public class PhabricatorNotifier extends Notifier implements SimpleBuildStep {
 
             // Ignore the result.
             nonDifferentialBuildTask.run();
-            return;
+            // if PHID is present, Harbormaster needs build status
+            if (CommonUtils.isBlank(phid)) {
+                return;
+            }
         }
 
         ConduitAPIClient conduitClient;

is a possible solution.

maroux avatar Jun 21 '18 21:06 maroux

Also, how do we call NonDifferentialHarbormasterTask from jenkins pipeline?

aadis avatar Jun 27 '18 08:06 aadis

@aadis that task is triggered if you run a job with phid and no diff id (or revision id). For example, if you enable phab integration for CI builds.

maroux avatar Jun 27 '18 16:06 maroux

Any change this will get fixed?

maroux avatar Aug 21 '18 16:08 maroux

What I realised by looking in the code is it only triggers for Stable builds. I wanted coverage even for unstable builds so removed that check.

aadis avatar Aug 21 '18 17:08 aadis