I have a Jenkins pipeline supported by Groovy in the git SCM which has stage inside steps.
Why I did it- To reuse the code. Actually our reusable code lies in a groovy method that has got stage. And we are calling this groovy method from steps. And it is causing the stage node to be hidden on blueocean. It is not considering the stage as a stage just because the stage has been called from steps.
Below is how blueocean view looks like. The Code Push and Test Execution stage is where the problem lies. The code looks like below-
tests = [:]
//code for other stages like Prepare, Initialize, Prepare App
stage('Test') {
stages{
stage('Cycle and Test Definition Prep') {
steps {
script {
//groovy code to populate tests variable
for (int i = 1; i <= NUMBER_OF_ORGS.toInteger(); ++i) {
def orgNumber = i;
tests['Org ' + orgNumber] = {
processOrg(orgNumber, cycleKey, definitionKey, newCycleName, folderName)
}
}
}
}
}
stage('Code Push and Test Execution') {
steps {
script {
parallel tests
}
}
}
}
}
}
void processOrg(int orgNumber, String testCycleID, String testCycleDefinition, String newCycleName, String testResultFolder) {
def orgUsername
def directory
stage ('Deployment' + orgNumber) {
//some code
}
}
I was expecting the stage Deployment 1 etc to show as a stage that does not happen.
PS:- I see https://stackoverflow.com/a/57507753/6532664 & What is the difference between a node, stage, and step in Jenkins pipelines? but still want to see if there is a way out. This is working perfectly but just not showing in blueocean and I have downside code to check failure stagees. Now because it is not recognized as a stage so my downside code is not working.

visual problem occurs because of different logic to render stages in blueocean and classic UI
all code inside of
script {}will treat as "scripted" pipelinejenkins classic UI shows "stage name" while blueocean shows branch name
tests['Org ' + orgNumber]- its your branch name for parallel codein perfect case need to use the same name of stage and name of branch for parallel
also would be better to use Map as arg
and use like
or