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

            atcarmo André Carmo created issue -
            atcarmo André Carmo made changes -
            Field Original Value New Value
            Description This issue can possibly be a duplicate version of JENKINS-30604.

            *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
            {code}
            @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());
                }
            {code}

            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.
            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
            {code}
            @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());
                }
            {code}

            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.
            atcarmo André Carmo made changes -
            Assignee André Carmo [ atcarmo ] Patrik Boström [ patbos ]
            atcarmo André Carmo made changes -
            Environment Latest versions of delivery-pipeline-plugin and nest-view-plugin.
            Jenkins 1.626
            Latest versions of delivery-pipeline-plugin and nested-view-plugin.
            Jenkins 1.626
            atcarmo André Carmo made changes -
            Link This issue is related to JENKINS-29521 [ JENKINS-29521 ]
            Hide
            atcarmo André Carmo added a comment -

            I think this is originated by JENKINS-29521.

            In fact I don't understand the fix for JENKINS-29521.

            Show
            atcarmo André Carmo added a comment - I think this is originated by JENKINS-29521 . In fact I don't understand the fix for JENKINS-29521 .
            Hide
            killdash9 Michael Andrews added a comment -

            This has been a problem for sometime. When using the Nested View and showing the status ball, if ANY job in Jenkins is "red" - then ALL the delivery Pipelines are red.

            Show
            killdash9 Michael Andrews added a comment - This has been a problem for sometime. When using the Nested View and showing the status ball, if ANY job in Jenkins is "red" - then ALL the delivery Pipelines are red.
            Hide
            killdash9 Michael Andrews added a comment -

            Great write-up on how to reproduce btw. Pinpoints the exact method where the bug is.

            Show
            killdash9 Michael Andrews added a comment - Great write-up on how to reproduce btw. Pinpoints the exact method where the bug is.
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 166301 ] JNJira + In-Review [ 182345 ]
            Hide
            tommysdk Tommy Tynjä added a comment -

            André Carmo Michael Andrews Is this still an issue with the latest version of the Delivery Pipeline Plugin (1.0.0)? Are you able to reproduce it still?

            If I run the attached test case (adjusted for upstream parameter) on 1.0.0 it passes:

                @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, DO_NOT_SHOW_UPSTREAM));
                    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());
                }
            

            Thank you for the thorough steps in the issue description, much appreciated!

            Show
            tommysdk Tommy Tynjä added a comment - André Carmo Michael Andrews Is this still an issue with the latest version of the Delivery Pipeline Plugin (1.0.0)? Are you able to reproduce it still? If I run the attached test case (adjusted for upstream parameter) on 1.0.0 it passes: @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, DO_NOT_SHOW_UPSTREAM)); 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()); } Thank you for the thorough steps in the issue description, much appreciated!
            tommysdk Tommy Tynjä made changes -
            Assignee Patrik Boström [ patbos ] Tommy Tynjä [ tommysdk ]
            tommysdk Tommy Tynjä made changes -
            Status Open [ 1 ] Closed [ 6 ]
            Resolution Cannot Reproduce [ 5 ]

              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: