jenkinsci / pipeline-graph-view-plugin

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

Parallel Stages Status Update Delay in Pipeline Execution #521

Open Deboprk opened 1 month ago

Deboprk commented 1 month ago

Jenkins and plugins versions report

Environment ```text Jenkins 2.440.2 Pipeline Graph View Plugin Version243.vc9e11fec486a_ ```

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

Ubuntu22

Reproduction steps

  1. Create dummy Job using below pipeline script( This job will be called using the other job )

    pipeline {
    agent any
    stages {
        stage('Hello') {
            steps {
                script{
                    if ("${params.StatusChoice}" == "Fail"){
                        error("Failing Job")
                    }
    
                    if ("${params.StatusChoice}" == "Unstable"){
                        unstable("unstable Job")
                    }
                }
            }
        }
    }
    }
  2. Create Test Job using below pipeline script

    pipeline {
    agent any
    stages {
        stage('Stage 1') {
            steps {
                echo 'This is stage 1'
            }
        }
        stage('Parallel Stage') {
            steps {
                script {
                    LinkedHashMap parallelStages = [:]
                    for (int i = 0; i < 3; i++) {
                        def stageName = "Stage P-${i}"
                        parallelStages[stageName] = {
                            script {
                                def stageStatus="Pass"
                                if ("${stageName}" == "Stage P-0") {
                                   sh "sleep 30"
                                }
                                if ("${stageName}" == "Stage P-1") {
                                    println("At stage 2")
                                    stageStatus = "Fail"
                                }
                                if ("${stageName}" == "Stage P-2") {
                                    println("At stage 3")
                                    stageStatus = "Unstable"
                                }
                                def childJobBuild = build(
                                    job: "dummy",
                                    propagate: false,
                                    wait: true,
                                    parameters: [
                                        string(name: 'StatusChoice', value: "${stageStatus}")
                                    ]
                                )
                                if (childJobBuild.result == "ABORTED" || childJobBuild.result == "FAILURE" ) {
                                    catchError(stageResult: 'FAILURE'){
                                        error("${childJobBuild.displayName} STATUS: ${childJobBuild.result}")
                                    }
                                }
                                if (childJobBuild.result == "UNSTABLE") {
                                    catchError(stageResult: 'UNSTABLE'){
                                        unstable("${childJobBuild.displayName} STATUS: ${childJobBuild.result}")
                                    }
                                }
    
                            }
                        }
                    }
                    parallel parallelStages
                }
            }
        }
    }
    }
  3. Trigger Test Job and this should allow you to reproduce the issue

Expected Results

At runtime the all stages should be updated

Actual Results

Initially all stages are shown passed even though there are failures only after pipeline execution completes the stages are shown correctly.

While Other stages are running: Image

After all the stages are completed Image

Anything else?

No response

Are you interested in contributing a fix?

No response