Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51671

JiraTestResultReporter-plugin does not work with Maven projects with modules

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Blocker
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      Jenkins version 2.107.3
      JiraTestReporter plugin version 2.0.6
    • Similar Issues:

      Description

      The current Maven jobs in Jenkins version 2.107.3 seems to create modules in the job directory. For example:

      For a maven job name test_jira_integration, the job directory actually has modules directory

      /var/lib/jenkins/jobs/Test/jobs/test_jira_integration/modules/com.xxxx$xxxxx

       

      This is the error output by Jenkins log:

       

      Jun 02, 2018 12:25:46 PM org.jenkinsci.plugins.JiraTestResultReporter.JiraUtils log

      INFO: No configs found for project Test/test_jira_integration/com.xxxx:xxxxx

       

      The config Jenkins use to build is actually inside /var/lib/jenkins/jobs/Test/jobs/test_jira_integration/modules/com.xxxx$xxxxx folder.

      The reason why it saids config not found is because your code uses a separate json file (JiraIssueJobConfigs.json) for the plugin configurations instead of config.xml. This file is not copied by Jenkins into the Maven modules folders before each build job.

       

      One possible solution is to read from the RootProject folder. The diff below is tested to work in our environment, but need full test and code review.

      diff --git a/src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/JobConfigMapping.java b/src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/JobConfigMapping.java
      index a2212a7..be2158e 100644
      — a/src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/JobConfigMapping.java
      +++ b/src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/JobConfigMapping.java
      @@ -146,7 +146,7 @@ public class JobConfigMapping {
      }

      private String getPathToJsonFile(AbstractProject project) {

      • return project.getRootDir().toPath().resolve(CONFIGS_FILE).toString() + ".json";
        + return project.getRootProject().getRootDir().toPath().resolve(CONFIGS_FILE).toString() + ".json";
        }

      /**
      diff --git a/src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/TestToIssueMapping.java b/src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/TestToIssueMapping.java
      index c7a1985..49d9f66 100644
      — a/src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/TestToIssueMapping.java
      +++ b/src/main/java/org/jenkinsci/plugins/JiraTestResultReporter/TestToIssueMapping.java
      @@ -21,6 +21,7 @@ import com.google.gson.JsonObject;
      import com.google.gson.stream.JsonReader;
      import com.google.gson.stream.JsonWriter;
      import hudson.matrix.MatrixProject;
      +import hudson.model.AbstractProject;
      import hudson.model.Job;
      import hudson.util.CopyOnWriteMap;
      import jenkins.model.Jenkins;
      @@ -85,7 +86,11 @@ public class TestToIssueMapping {

      • @return
        */
        private String getPathToFileMap(Job job) {
      • return job.getRootDir().toPath().resolve(MAP_FILE_NAME).toString();
        + if (job instanceof AbstractProject) {
        + AbstractProject project = (AbstractProject) job;
        + return project.getRootProject().getRootDir().toPath().resolve(MAP_FILE_NAME).toString();
        + }
        + return job.getRootDir().toPath().resolve(MAP_FILE_NAME).toString();
        }

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            Assignee:
            catalinluta Catalin Luta
            Reporter:
            observer_m Yuqing Mai
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: