Search code examples
jenkins-pipelinejenkins-blueocean

Jenkins dynamic Pipeline not showing all stages in BlueOcean


I have a Jenkins pipeline script with the key pieces shown below. Everything seems to be executing in the background but is not showing on BlueOcean.

enter image description here

Am I doing something wrong or it is some kind of bug on the UI?

def projects = [
    [name: 'API', folder: 'api-tests', repo: 'url'],
    [name: 'UI',folder: 'selenium-tests', repo: 'url']
]

// Create List of build stages to suit
def jobs = [:]

pipeline {
    agent {
        kubernetes {
            cloud "url"
            yaml """contents"""
        }
    }
    stages {
        stage('Downstream Testing') {
            steps {
                script{
                    // Set up List<Map<String,Closure>> describing the builds
                    projects.each { project ->
                        print "Adding stages for ${project.folder}"
        
                        jobs[project.name] = {
                            stage("Checkout Project") {
                                ...
                            }
                            stage("Smoke Tests") {
                                dir("${project.folder}") {
                                        container('maven') {
                                            // Run the maven build
                                            sh """mvn package test"""
                                        }
                                    }
                                }
                            }
                    }
                    
                    // Run all Nth step for all Projects in Parallel. 
                    parallel jobs
                }
            }   
        }
    }
}

Solution

  • Yes, It seems there is a bug in the Blueocean UI.

    The scenario works fine for the scripted pipeline but the same fail in declarative pipeline

    scripted pipeline

    def j=[:]
    node {
        [
            [name: "api", folder: "api"],
            [name: "ui", folder: "ui"]
        ].each { m -> 
            j[m.name] = {
                stage('a') {
                    echo "A"
                }
                stage('b') {
                    echo "B"
                }
            }
        }
        parallel j
    }
    

    enter image description here

    declarative pipeline

    pipeline {
        agent any;
        stages {
            stage("parallel") {
                steps {
                    script {
                        def j=[:]
                        [
                            [name: "api", folder: "api"],
                            [name: "ui", folder: "ui"]
                        ].each { m -> 
                            j[m.name] = {
                                stage('a') {
                                    echo "A"
                                }
                                stage('b') {
                                    echo "B"
                                }
                            }
                        }
                        parallel j
                    }
                }
            }
        }
    }
    

    enter image description here