[JIRA] (JENKINS-53162) Blueocean support for visualizing stages in parallel block in scripted pipeline

2 views
Skip to first unread message

joerg.schwaerzler@infineon.com (JIRA)

unread,
Aug 21, 2018, 8:41:01 AM8/21/18
to jenkinsc...@googlegroups.com
Joerg Schwaerzler created an issue
 
Jenkins / New Feature JENKINS-53162
Blueocean support for visualizing stages in parallel block in scripted pipeline
Issue Type: New Feature New Feature
Assignee: Unassigned
Attachments: image-2017-08-14-10-34-10-452.png
Components: blueocean-plugin
Created: 2018-08-21 12:40
Labels: blueocean
Priority: Major Major
Reporter: Joerg Schwaerzler

As suggested in JENKINS-38442 I created this new feature request which I would like to use to explicitely target the support for visualising one level of stages in parallel blocks, like:

parallel (
  "first": {
    stage("JUnit") {
    }
    stage("Firefox") { 
    }
  },
  "second" : {
    stage("D3Unit") {
    }
    stage("Edge") {
    }
  },
  "third" : {
    stage("Safari") {
    }
  }
)

As an example on how a possible visualization could look like please check the attached png.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

Jared@Kauppi.la (JIRA)

unread,
Aug 21, 2018, 8:46:01 AM8/21/18
to jenkinsc...@googlegroups.com
Jared Kauppila commented on New Feature JENKINS-53162
 
Re: Blueocean support for visualizing stages in parallel block in scripted pipeline

Very interested in this as we only used scripted pipelines and was disappointed that the other issue only addressed declarative.

vzedano.registros@gmail.com (JIRA)

unread,
Aug 29, 2018, 4:59:02 PM8/29/18
to jenkinsc...@googlegroups.com

Hi,

I would definitely love to see this on scripted pipelines as well

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

oliver@volatilevoid.net (JIRA)

unread,
Oct 25, 2018, 6:21:05 PM10/25/18
to jenkinsc...@googlegroups.com

I dug into this a little and found that BlueOcean explicitly disables rendering sequential stages in parallel branches unless the build is a declarative pipeline run. So a quick and dirty workaround is to fake a declarative pipeline in a scripted one. Then arrange your stages similarly to what declarative would do (namely create a wrapper stage with the same name as each parallel branch), and it will be rendered nicely.

Needless to say, this is an ugly hack and might break in unforeseen ways. Though it seems to work in my tests, and the only side effect I saw was that a "Restart from Stage" option appeared in the build's menu, with an empty dropdown list. This seems benign enough, but I don't know what else it could cause, so be warned.

So how do you fake a declarative run? BlueOcean checks for an action of type ExecutionModelAction, so that's what we have to add:

import org.jenkinsci.plugins.pipeline.modeldefinition.actions.ExecutionModelAction
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTStages

if (!currentBuild.rawBuild.getAction(ExecutionModelAction))
    currentBuild.rawBuild.addAction(new ExecutionModelAction(new ModelASTStages(null)))

This won't work in a sandboxed script, but it does in a global shared library. So it's probably not worth the effort (and potential risk) to make jobs with hand-written parallel-sequential stages render properly, but it might just be a workaround if you generate jobs with such a structure from library functions.

joerg.schwaerzler@infineon.com (JIRA)

unread,
Nov 8, 2018, 2:27:09 PM11/8/18
to jenkinsc...@googlegroups.com

leromarinvit: Doesn't work for me using BlueOcean 1.8.2. That is: The job's green but BlueOcean still won't show me any stages which have been defined inside a parallel branch. Which version of BlueOcean did you use?

jakehilborn@gmail.com (JIRA)

unread,
May 30, 2019, 5:50:14 PM5/30/19
to jenkinsc...@googlegroups.com
Jake Hilborn updated an issue
 
Change By: Jake Hilborn
Attachment: Screen Shot 2019-05-30 at 2.49.21 PM.png

jakehilborn@gmail.com (JIRA)

unread,
May 30, 2019, 5:50:14 PM5/30/19
to jenkinsc...@googlegroups.com
Jake Hilborn commented on New Feature JENKINS-53162
 
Re: Blueocean support for visualizing stages in parallel block in scripted pipeline

leromarinvit Wow that actually works for scripted pipelines. The key is to have a stage inside the parallel block that has the same name as the parallel stage. Here's a working example.

parallel (
  "one": {
    stage("one") {
      stage("one-child1") {
        println "one-child1"
      }
      stage("one-child2") {
        println "one-child2"
      }
    }
  },
  "two": {
    stage("two") {
      stage("two-child1") {
        println "two-child1"
      }
      stage("two-child2") {
        println "two-child2"
      }
    }
  },
  "three": {
    stage("three") {
      stage("three-child1") {
        println "three-child1"
      }
      stage("three-child2") {
        println "three-child2"
      }
    }
  }
) 

zdmerlin@gmail.com (JIRA)

unread,
Jun 25, 2019, 5:42:03 AM6/25/19
to jenkinsc...@googlegroups.com

Hi Jake,

Can you please let us know which version of Jenkins and Bitbucket Plugin you are using ?

I tested your pipeline code using Jenkins ver. 2.176.1 and Blue Ocean version 1.17.0 and the rendering is showing only one stage per parallel.

Thanks

 

jakehilborn@gmail.com (JIRA)

unread,
Jun 25, 2019, 12:29:09 PM6/25/19
to jenkinsc...@googlegroups.com
Jake Hilborn edited a comment on New Feature JENKINS-53162
I believe I tested this on Jenkins 2.164.2. However, it doesn't work well enough to be usable. Console logs are duplicated and shown in multiple stages when using this sequential inside parallel hack. It makes the approach useless. For example, in the image I posted above, I would see "one-child2" console messages inside the "one-child2" stage and the "two-child2" stage which makes debugging very confusing.

jakehilborn@gmail.com (JIRA)

unread,
Jun 25, 2019, 12:29:09 PM6/25/19
to jenkinsc...@googlegroups.com

I believe I tested this on 2.164.2. However, it doesn't work well enough to be usable. Console logs are duplicated and shown in multiple stages when using this sequential inside parallel hack. It makes the approach useless. For example, in the image I posted above, I would see "one-child2" console messages inside the "one-child2" stage and the "two-child2" stage which makes debugging very confusing.

zdmerlin@gmail.com (JIRA)

unread,
Jun 27, 2019, 9:15:03 AM6/27/19
to jenkinsc...@googlegroups.com

andrius-jenkins@stikonas.eu (JIRA)

unread,
Jun 28, 2019, 5:11:05 AM6/28/19
to jenkinsc...@googlegroups.com

It doesn't seem any less usable than declarative pipeline. I tried with Jenkins version 2.182 and Blue Ocean 1.17.0.

I can see parallel stages and all branches show the same logs of first branch while job is running (shows fine after completion) but that's not specific to scripted pipeline (see https://issues.jenkins-ci.org/browse/JENKINS-58009).

andrius-jenkins@stikonas.eu (JIRA)

unread,
Jun 28, 2019, 5:32:04 AM6/28/19
to jenkinsc...@googlegroups.com
Andrius Štikonas edited a comment on New Feature JENKINS-53162
It doesn't seem any less usable than declarative pipeline. I tried with Jenkins version 2.182 and Blue Ocean 1.17.0.

When I can see parallel stages and view logs while job is running all branches with sequential parallel stages show the same logs of first branch while job is running ( everything shows fine after completion job completes ) but that's not specific to scripted pipeline (see https://issues.jenkins-ci.org/browse/JENKINS-58009).

andrius-jenkins@stikonas.eu (JIRA)

unread,
Sep 5, 2019, 6:20:03 PM9/5/19
to jenkinsc...@googlegroups.com

It seems that in latest Blue Ocean it works well and is usable.

Shall we close this as fixed?

jglick@cloudbees.com (JIRA)

unread,
Sep 6, 2019, 10:15:06 AM9/6/19
to jenkinsc...@googlegroups.com

Andrius Štikonas if you have one, a minimal example (script + screenshot) would be appreciated.

andrius-jenkins@stikonas.eu (JIRA)

unread,
Sep 11, 2019, 6:52:03 PM9/11/19
to jenkinsc...@googlegroups.com

My example is the same as above. It's just that in version 1.9.0 all those bugs that prevented clicking on stages got fixed (they affected declarative pipeline too).
import org.jenkinsci.plugins.pipeline.modeldefinition.actions.ExecutionModelActionimport org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTStagesif (!currentBuild.rawBuild.getAction(ExecutionModelAction))
currentBuild.rawBuild.addAction(new ExecutionModelAction(new ModelASTStages(null)))

parallel (
"one": {
stage("one") {
stage("one-child1")

{ println "one-child1" }

stage("one-child2") {
println "one-child2"
}
}
},
"two": {
stage("two") {
stage("two-child1")

{ println "two-child1" }

stage("two-child2") {
println "two-child2"
}
}
},
"three": {
stage("three") {
stage("three-child1")

{ println "three-child1" }

stage("three-child2") {
println "three-child2"
}
}
}
)

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

andrius-jenkins@stikonas.eu (JIRA)

unread,
Sep 11, 2019, 6:53:04 PM9/11/19
to jenkinsc...@googlegroups.com
Andrius Štikonas edited a comment on New Feature JENKINS-53162
My example is the same as above. It's just that in version 1.9.0 all those bugs that prevented clicking on stages got fixed (they affected declarative pipeline too).

{{ 
import org.jenkinsci.plugins.pipeline.modeldefinition.actions.ExecutionModelActionimport org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTStagesif (!currentBuild.rawBuild.getAction(ExecutionModelAction))
}}{{{{     currentBuild.rawBuild.addAction(new ExecutionModelAction(new ModelASTStages(null)))

}}}}{{ parallel ( }}
{{   "one": \ { }}
{{     stage("one") { }}
{{       stage("one-child1") }} {
{Unknown macro: \{         println "one-child1"
      }
}}{{       stage("one-child2") \ { }}
{{         println "one-child2" }}
{{       } }}
{{     } }}
{{   }, }}
{{   "two": \ { }}
{{     stage("two") { }}
{{       stage("two-child1") }} {
{Unknown macro: \{         println "two-child1"
      }
}}{{       stage("two-child2") \ { }}
{{         println "two-child2" }}
{{       } }}
{{     } }}
{{   }, }}
{{   "three": \ { }}
{{     stage("three") { }}
{{       stage("three-child1") }} {
{Unknown macro: \{         println "three-child1"
      }
}}{{       stage("three-child2") \ { }}
{{         println "three-child2" }}
{{       } }}
{{     } }}
{{   } }}
{{ ) }}{{ }}

andrius-jenkins@stikonas.eu (JIRA)

unread,
Sep 11, 2019, 6:54:25 PM9/11/19
to jenkinsc...@googlegroups.com
Andrius Štikonas edited a comment on New Feature JENKINS-53162
My example is the same as above. It's just that in version 1.9.0 all those bugs that prevented clicking on stages got fixed (they affected declarative pipeline too).

 
{code:java}
import org.jenkinsci.plugins.pipeline.modeldefinition.actions.ExecutionModelAction
import org.jenkinsci.plugins.pipeline.modeldefinition.ast.ModelASTStages

if (!currentBuild.rawBuild.getAction(ExecutionModelAction))
    currentBuild.rawBuild.addAction(new ExecutionModelAction(new ModelASTStages(null)))

parallel (
  "one": {
    stage("one") {
      stage("one-child1") {
        println "one-child1"
      }
      stage("one-child2") {
        println "one-child2"
      }
    }
  },
  "two": {
    stage("two") {
      stage("two-child1") {
        println "two-child1"
      }
      stage("two-child2") {
        println "two-child2"
      }
    }
  },
  "three": {
    stage("three") {
      stage("three-child1") {
        println "three-child1"
      }
      stage("three-child2") {
        println "three-child2"
      }
    }
  }
)

{ code}

andrius-jenkins@stikonas.eu (JIRA)

unread,
Sep 11, 2019, 6:54:27 PM9/11/19
to jenkinsc...@googlegroups.com
Andrius Štikonas edited a comment on New Feature JENKINS-53162
My example is the same as above. It's just that in version 1.9.0 all those bugs that prevented clicking on stages got fixed (they affected declarative pipeline too).

{{  
{code:java}
import org.jenkinsci.plugins.pipeline.modeldefinition.actions. ExecutionModelActionimport ExecutionModelAction
import
org.jenkinsci.plugins.pipeline.modeldefinition.ast. ModelASTStagesif ModelASTStages

if
(!currentBuild.rawBuild.getAction(ExecutionModelAction)) }}{{{{
currentBuild.rawBuild.addAction(new ExecutionModelAction(new ModelASTStages(null))) }}}}{{parallel (}}
{{ "one": {}}
{{ stage("one") {}}

{
{ stage("one-child1") code } }{{Unknown macro: \{ println "one-child1" }}}{{stage("one-child2") {}}
{{ println "one-child2"}}
{{ }}}
{{ }}}
{{ },}}
{{ "two": {}}
{{ stage("two") {}}
{{ stage("two-child1")}}{{Unknown macro: \{ println "two-child1" }}}{{stage("two-child2") {}}

{{ println "two-child2"}}
{{ }}}
{{ }}}
{{ },}}
{{ "three": {}}
{{ stage("three") {}}
{{ stage("three-child1")}}{{Unknown macro: \{ println "three-child1" }}}{{stage("three-child2") {}}
{{ println "three-child2"}}
{{ }}}
{{ }}}
{{ }}}
{{ )}}{{ }}

jglick@cloudbees.com (JIRA)

unread,
Sep 12, 2019, 10:43:05 AM9/12/19
to jenkinsc...@googlegroups.com

If you have to use currentBuild.rawBuild, or import generally, then this is clearly not fixed.

blanked-out@hotmail.com (JIRA)

unread,
Nov 14, 2019, 1:53:04 PM11/14/19
to jenkinsc...@googlegroups.com

Yup I agree with Jesse Glick on that. The example Andrius Štikonas shared is a workaround instead of a fix. I would imagine a fix would be that it simply works out of the box similar to how it does for declarative pipeline.

 

olamy@apache.org (JIRA)

unread,
Dec 2, 2019, 4:16:04 PM12/2/19
to jenkinsc...@googlegroups.com

olamy@apache.org (JIRA)

unread,
Dec 2, 2019, 4:17:13 PM12/2/19
to jenkinsc...@googlegroups.com

olamy@apache.org (JIRA)

unread,
Dec 2, 2019, 4:17:14 PM12/2/19
to jenkinsc...@googlegroups.com
Olivier Lamy closed an issue as Fixed
 
Change By: Olivier Lamy
Status: Open Closed
Resolution: Fixed

joerg.schwaerzler@infineon.com (JIRA)

unread,
Dec 3, 2019, 3:23:04 AM12/3/19
to jenkinsc...@googlegroups.com
Joerg Schwaerzler commented on New Feature JENKINS-53162
 
Re: Blueocean support for visualizing stages in parallel block in scripted pipeline

Great to see this is finally available

Olivier Lamy: Can you already tell when there will be a release containing this fix?

Reply all
Reply to author
Forward
0 new messages