jenkinsci / pipeline-graph-view-plugin

https://plugins.jenkins.io/pipeline-graph-view/
Other
107 stars 55 forks source link

The plugin in unable to show more than two stages inside each parallel block #63

Closed reddwarf69 closed 2 years ago

reddwarf69 commented 2 years ago

Jenkins and plugins versions report

Environment ``` Jenkins: 2.346.1 OS: Linux - 5.15.0-40-generic --- ace-editor:1.1 analysis-model-api:10.12.0 ansicolor:1.0.1 antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-1.0 authentication-tokens:1.4 authorize-project:1.4.0 blueocean:1.25.5 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.25.5 blueocean-commons:1.25.5 blueocean-config:1.25.5 blueocean-core-js:1.25.5 blueocean-dashboard:1.25.5 blueocean-display-url:2.4.1 blueocean-events:1.25.5 blueocean-git-pipeline:1.25.5 blueocean-github-pipeline:1.25.5 blueocean-i18n:1.25.5 blueocean-jwt:1.25.5 blueocean-personalization:1.25.5 blueocean-pipeline-api-impl:1.25.5 blueocean-pipeline-editor:1.25.5 blueocean-pipeline-scm-api:1.25.5 blueocean-rest:1.25.5 blueocean-rest-impl:1.25.5 blueocean-web:1.25.5 bootstrap4-api:4.6.0-5 bootstrap5-api:5.1.3-7 bouncycastle-api:2.26 branch-api:2.1046.v0ca_37783ecc5 caffeine-api:2.9.3-65.v6a_47d0f4d1fe checks-api:1.7.4 cloudbees-bitbucket-branch-source:773.v4b_9b_005b_562b_ cloudbees-folder:6.729.v2b_9d1a_74d673 cobertura:1.17 code-coverage-api:3.0.1 command-launcher:84.v4a_97f2027398 credentials:1129.vef26f5df883c credentials-binding:523.vd859a_4b_122e6 custom-build-properties:2.79.vc095ccc85094 data-tables-api:1.12.1-2 display-url-api:2.3.6 docker-commons:1.19 docker-workflow:1.29 dtkit-api:3.0.1 durable-task:496.va67c6f9eefa7 echarts-api:5.3.3-1 extended-choice-parameter:346.vd87693c5a_86c extended-read-permission:3.2 favorite:2.4.1 file-operations:1.11 font-awesome-api:6.1.1-1 forensics-api:1.15.1 git:4.11.3 git-client:3.11.0 git-forensics:1.9.0 git-server:1.11 github:1.34.4 github-api:1.303-400.v35c2d8258028 github-branch-source:1656.v77eddb_b_e95df github-checks:1.0.18 github-oauth:0.39 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 htmlpublisher:1.30 jackson2-api:2.13.3-285.vc03c0256d517 javax-activation-api:1.2.0-3 javax-mail-api:1.6.2-6 jaxb:2.3.6-1 jdk-tool:1.5 jenkins-design-language:1.25.5 jira:3.7.1 jjwt-api:0.11.5-77.v646c772fddb_0 jquery:1.12.4-1 jquery3-api:3.6.0-4 jsch:0.1.55.2 junit:1119.1121.vc43d0fc45561 ldap:2.10 lockable-resources:2.15 mailer:414.vcc4c33714601 matrix-auth:3.1.3 matrix-project:772.v494f19991984 mina-sshd-api-common:2.8.0-21.v493b_6b_db_22c6 mina-sshd-api-core:2.8.0-21.v493b_6b_db_22c6 momentjs:1.1.1 okhttp-api:4.9.3-105.vb96869f8ac3a pipeline-build-step:2.18 pipeline-graph-analysis:195.v5812d95a_a_2f9 pipeline-graph-view:51.v5a693b766483 pipeline-groovy-lib:593.va_a_fc25d520e9 pipeline-input-step:449.v77f0e8b_845c4 pipeline-milestone-step:101.vd572fef9d926 pipeline-model-api:2.2097.v33db_b_de764b_e pipeline-model-definition:2.2097.v33db_b_de764b_e pipeline-model-extensions:2.2097.v33db_b_de764b_e pipeline-rest-api:2.24 pipeline-stage-step:293.v200037eefcd5 pipeline-stage-tags-metadata:2.2097.v33db_b_de764b_e pipeline-stage-view:2.24 plain-credentials:1.8 plugin-util-api:2.17.0 popper-api:1.16.1-3 popper2-api:2.11.5-2 prism-api:1.28.0-2 pubsub-light:1.16 role-strategy:521.vcf7a_3a_8dde42 scm-api:608.vfa_f971c5a_a_e9 script-security:1175.v4b_d517d6db_f0 slack:616.v03b_1e98d13dd snakeyaml-api:1.30.2-76.vc104f7ce9870 sse-gateway:1.25 ssh-credentials:291.v8211e4f8efb_c ssh-slaves:1.821.vd834f8a_c390e sshd:3.242.va_db_9da_b_26a_c3 structs:318.va_f3ccb_729b_71 throttle-concurrents:2.8 token-macro:293.v283932a_0a_b_49 trilead-api:1.57.v6e90e07157e1 variant:1.4 warnings-ng:9.13.0 workflow-aggregator:590.v6a_d052e5a_a_b_5 workflow-api:1165.v02c3db_a_6b_e36 workflow-basic-steps:948.v2c72a_091b_b_68 workflow-cps:2725.v7b_c717eb_12ce workflow-durable-task-step:1155.v79567b_e0a_2de workflow-job:1189.va_d37a_e9e4eda_ workflow-multibranch:716.vc692a_e52371b_ workflow-scm-step:400.v6b_89a_1317c9a_ workflow-step-api:625.vd896b_f445a_f8 workflow-support:820.vd1a_6cc65ef33 xunit:3.1.0 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu 22.04, both controller and agent (Built-In Node)

Reproduction steps

Run this pipeline

pipeline {
  stages {
    stage('Test') {
      matrix {
        axes {
          axis {
            name 'PLATFORM'
            values '1','2'
          }
        }

        stages {
          stage('Stage 1') {
            steps {
              echo "${PLATFORM}"
            }
          }

          stage('Stage 2') {
            steps {
              echo "${PLATFORM}"
            }
          }

          stage('Stage 3') {
            steps {
              echo "${PLATFORM}"
            }
          }
        }
      }
    }
  }
}

Expected Results

I would expect to see something similar to what Blue Ocean shows Blue

Actual Results

But I get this Graph

Anything else?

No response

soprano8086 commented 2 years ago

I am having same issue

Environment Jenkins: [Jenkins 2.346.2] Pipeline Graph View Plugin Version51.v5a693b766483

Script: from: https://github.com/darinpope/jenkins-example-parallel/blob/main/Jenkinsfile-4

pipeline {
  agent {
        node {
            label "maven2"
        }
    }
  stages {
    stage('build and run') {
      parallel {
        stage('linux-armv6') {

          stages {
            stage('build') {
              steps {
                sh 'echo'
              }
            }
            stage('run') {
              steps {
                sh 'echo'
              }
            }
          }
        }
        stage('linux-amd64') {
          stages {
            stage('build') {
              steps {
                sh 'echo'
              }
            }
            stage('run') {
              steps {
                sh 'echo'
              }
            }
            stage('unit test') {
              steps {
                sh 'echo unit test'
              }
            }
            stage('load test') {
              steps {
                sh 'echo load test'
              }
            }
            stage('deploy to storage') {
              steps {
                sh 'echo deploy to storage'
              }
            }
          }
        }      
        stage('darwin-amd64') {
          stages {
            stage('build') {
              steps {
                sh 'echo'
              }
            }
            stage('run') {
              steps {
                sh 'echo'
              }
            }
            stage('unit test') {
              steps {
                sh 'echo unit test'
              }
            }
          }
        }      
      }
    }
  }
}

Actual result

image

Expect: image This is screen shot from https://www.youtube.com/watch?v=6wNbjP2WUMo at 11:30

mikedld commented 2 years ago

Looks like tree endpoint (/pipeline-graph/tree) returns properly grouped stages while graph endpoint (/pipeline-graph/graph) doesn't. Maybe we can reimplement one based on another, if we even need both?

mikedld commented 2 years ago

The below patch seems to work in my limited testing. @timja do you see any issues with the approach or do you want me to work up a PR?

diff --git a/src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraph.tsx b/src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraph.tsx
index f396258..892af5d 100644
--- a/src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraph.tsx
+++ b/src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraph.tsx
@@ -76,7 +76,7 @@ export class PipelineGraph extends React.Component {
       onPipelineDataReceived,
       onPollingError,
       onPipelineComplete,
-      this.props.path ?? "graph"
+      "tree"
     );
   }

diff --git a/src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraphLayout.ts b/src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraphLayout.ts
index 8f81f87..63441a9 100644
--- a/src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraphLayout.ts
+++ b/src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraphLayout.ts
@@ -112,21 +112,17 @@ function createNodeColumns(
       const rowNodes: Array<NodeInfo> = [];
       let nodeStage: StageInfo | undefined = firstStageForRow;
       if (!collasped) {
-        while (nodeStage) {
-          if (nodeStage.seqContainerName) {
-            column.hasBranchLabels = true;
-          }
-
+        column.hasBranchLabels = !!nodeStage.name;
+        for (const childStage of nodeStage.children) {
           rowNodes.push({
             x: 0, // Layout is done later
             y: 0,
-            name: nodeStage.name,
-            id: nodeStage.id,
-            stage: nodeStage,
+            name: childStage.name,
+            id: childStage.id,
+            stage: { ...childStage, seqContainerName: nodeStage.name },
             isPlaceholder: false,
-            key: "n_" + nodeStage.id,
+            key: "n_" + childStage.id,
           });
-          nodeStage = nodeStage.nextSibling;
         }
         column.rows.push(rowNodes);
       } else {
mikedld commented 2 years ago

Spoke too soon. It works better for the test pipeline in https://github.com/jenkinsci/pipeline-graph-view-plugin/issues/63#issuecomment-1235178381 but breaks for my own yielding an empty page :)

timja commented 2 years ago

if you can reproduce it in a minimal unit test in this repo with just the stages that would be useful.

I haven't had much time to work on this repo but I would like to address some of the issues.

(Working quality pull requests will certainly be merged here, especially with tests reproducing the issue)

LCerebo commented 2 years ago

Same problem here, not sure what I can do to help, but I'm happy to contribute!

Environment ```text Jenkins: 2.361.1 OS: Linux - 5.15.0-46-generic --- Office-365-Connector:4.17.0 Parameterized-Remote-Trigger:3.1.6.3 ace-editor:1.1 antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-138.v4e7d9a_7b_a_e61 authentication-tokens:1.4 blueocean:1.25.8 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.25.8 blueocean-commons:1.25.8 blueocean-config:1.25.8 blueocean-core-js:1.25.8 blueocean-dashboard:1.25.8 blueocean-display-url:2.4.1 blueocean-events:1.25.8 blueocean-git-pipeline:1.25.8 blueocean-github-pipeline:1.25.8 blueocean-i18n:1.25.8 blueocean-jira:1.25.8 blueocean-jwt:1.25.8 blueocean-personalization:1.25.8 blueocean-pipeline-api-impl:1.25.8 blueocean-pipeline-editor:1.25.8 blueocean-pipeline-scm-api:1.25.8 blueocean-rest:1.25.8 blueocean-rest-impl:1.25.8 blueocean-web:1.25.8 bootstrap4-api:4.6.0-5 bootstrap5-api:5.2.0-3 bouncycastle-api:2.26 branch-api:2.1046.v0ca_37783ecc5 build-timeout:1.24 caffeine-api:2.9.3-65.v6a_47d0f4d1fe checks-api:1.7.5 cloudbees-bitbucket-branch-source:791.vb_eea_a_476405b cloudbees-folder:6.758.vfd75d09eea_a_1 command-launcher:84.v4a_97f2027398 commons-lang3-api:3.12.0-36.vd97de6465d5b_ commons-text-api:1.9-19.v8df45c678366 configuration-as-code:1512.vb_79d418d5fc8 credentials:1143.vb_e8b_b_ceee347 credentials-binding:523.vd859a_4b_122e6 cucumber-reports:5.7.3 display-url-api:2.3.6 docker-commons:1.21 docker-workflow:521.v1a_a_dd2073b_2e durable-task:500.v8927d9fd99d8 echarts-api:5.3.3-1 email-ext:2.91 extended-read-permission:3.2 external-monitor-job:192.ve979ca_8b_3ccd favorite:2.4.1 font-awesome-api:6.1.2-1 git:4.11.5 git-client:3.11.2 git-server:99.va_0826a_b_cdfa_d github:1.35.0 github-api:1.303-400.v35c2d8258028 github-branch-source:1694.vd46793a_c4a_57 gitlab-plugin:1.5.35 gradle:1.39.4 greenballs:1.15.1 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 htmlpublisher:1.30 instance-identity:116.vf8f487400980 jackson2-api:2.13.3-285.vc03c0256d517 jacoco:3.3.2 jakarta-activation-api:2.0.1-1 jakarta-mail-api:2.0.1-1 javax-activation-api:1.2.0-4 javax-mail-api:1.6.2-7 jaxb:2.3.6-1 jdk-tool:55.v1b_32b_6ca_f9ca jenkins-design-language:1.25.8 jersey2-api:2.37-1 jira:3.8 jjwt-api:0.11.5-77.v646c772fddb_0 jnr-posix-api:3.1.15-1 jquery-detached:1.2.1 jquery3-api:3.6.0-4 jsch:0.1.55.61.va_e9ee26616e7 junit:1119.1121.vc43d0fc45561 ldap:2.12 lockable-resources:2.16 mailer:438.v02c7f0a_12fa_4 matrix-auth:3.1.5 matrix-project:785.v06b_7f47b_c631 mercurial:1251.va_b_121f184902 mina-sshd-api-common:2.9.1-44.v476733c11f82 mina-sshd-api-core:2.9.1-44.v476733c11f82 momentjs:1.1.1 oic-auth:1.8 okhttp-api:4.9.3-108.v0feda04578cf pam-auth:1.10 parameterized-scheduler:1.1 pipeline-build-step:2.18 pipeline-graph-analysis:195.v5812d95a_a_2f9 pipeline-graph-view:51.v5a693b766483 pipeline-groovy-lib:612.v84da_9c54906d pipeline-input-step:449.v77f0e8b_845c4 pipeline-milestone-step:101.vd572fef9d926 pipeline-model-api:2.2114.v2654ca_721309 pipeline-model-declarative-agent:1.1.1 pipeline-model-definition:2.2114.v2654ca_721309 pipeline-model-extensions:2.2114.v2654ca_721309 pipeline-rest-api:2.24 pipeline-stage-step:296.v5f6908f017a_5 pipeline-stage-tags-metadata:2.2114.v2654ca_721309 pipeline-stage-view:2.24 plain-credentials:139.ved2b_9cf7587b plugin-util-api:2.17.0 popper-api:1.16.1-3 popper2-api:2.11.6-1 pubsub-light:1.17 resource-disposer:0.20 scm-api:621.vda_a_b_055e58f7 script-security:1175.v4b_d517d6db_f0 slack:616.v03b_1e98d13dd snakeyaml-api:1.31-84.ve43da_fb_49d0b sonar:2.14 sse-gateway:1.26 ssh-credentials:305.v8f4381501156 sshd:3.249.v2dc2ea_416e33 structs:324.va_f5d6774f3a_d timestamper:1.20 token-macro:308.v4f2b_ed62b_b_16 trilead-api:2.72.v2a_3236754f73 variant:59.vf075fe829ccb windows-slaves:1.8.1 workflow-aggregator:590.v6a_d052e5a_a_b_5 workflow-api:1192.v2d0deb_19d212 workflow-basic-steps:994.vd57e3ca_46d24 workflow-cps:2759.v87459c4eea_ca_ workflow-cps-global-lib:588.v576c103a_ff86 workflow-durable-task-step:1199.v02b_9244f8064 workflow-job:1232.v5a_4c994312f1 workflow-multibranch:716.vc692a_e52371b_ workflow-scm-step:400.v6b_89a_1317c9a_ workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:838.va_3a_087b_4055b ws-cleanup:0.43 ```
mikedld commented 2 years ago

I'm working on a PR, this will be a frontend-only change.

reddwarf69 commented 2 years ago

Not only this fixes the issue, this plugin is now able to give a correct view of something Blue Ocean is unable to.

Even with SCRIPT_SPLITTING_TRANSFORMATION I was getting "Method Code Too Large" errors (https://docs.cloudbees.com/docs/cloudbees-ci-kb/latest/troubleshooting-guides/method-code-too-large-error), so I ended up replacing a matrix step with a "script { parallel() }" and Blue Ocean started rendering a useless graph, missing stages. I guess I can now uninstall Blue Ocean.