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

Wrong pipeline results due to bug in DeliveryPipelineView.getItems()

    Details

    • Similar Issues:

      Description

      This issue can possibly be a duplicate version of JENKINS-30604.

      This is a bug of Delivery Pipeline Plugin, not Nested View Plugin.

      How to reproduce in GUI
      Pre-conditions:

      • Have those plugins installed
      • Have at least 2 jobs;
      • Have at least one job that failed in the latest build (mandatory for this to be reproducible)
      • Have a Nested View configured
      • In that Nested View, add a new view that is a Delivery Pipeline View.
      • Add only one job to the Delivery Pipeline View, at make sure that job runs with SUCCESS.
      • Run the Delivery Pipeline and make sure the job passes.
      • Return to the Nested View

      Expected Result

      • Since the only job of the Delivery Pipeline passed, that pipeline should be shown as SUCCESS in the Nested View.

      Actual Result:

      • The Nested View shows the pipeline as FAILED.

      How to reproduce with the Nested View Plugin source code

      • Download the source code from GitHub
      • Debug the code (having both plugins installed in your Jenkins instance)
      • The method getWorstResultForNormalView(View v) calls v.getItems() which returns ALL jobs existing in Jenkins, not only the jobs for that view.

      This tells me getItems() implementation of DeliveryPipelineView is wrong.

      How to reproduce with the Delivery Pipeline Plugin source code
      Add the following JUnit test

      @Test
          public void testGetItemsAndContainsWithProjectsNotInView() throws Exception {
              FreeStyleProject build = jenkins.createFreeStyleProject("build");
              jenkins.createFreeStyleProject("sonar");
              jenkins.createFreeStyleProject("packaging");
      
              jenkins.getInstance().rebuildDependencyGraph();
      
              List<DeliveryPipelineView.ComponentSpec> specs = new ArrayList<DeliveryPipelineView.ComponentSpec>();
              specs.add(new DeliveryPipelineView.ComponentSpec("Comp", "build", NONE));
              DeliveryPipelineView view = new DeliveryPipelineView("name");
              view.setComponentSpecs(specs);
              jenkins.getInstance().addView(view);
      
              assertTrue(view.contains(build));
      
              Collection<TopLevelItem> items =  view.getItems();
              assertEquals(1, items.size());
          }
      

      This test fails on the last line with java.lang.AssertionError: expected:<1> but was:<3>.

      As you can see, our Jenkins instance has 3 projects, but there is no connection (downstream trigger) between the "build" project and the others. The DeliveryPipelineView starts with the "build" project, so the view should only have 1 item, not 3.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tommysdk Tommy Tynjä
                Reporter:
                atcarmo André Carmo
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: