Declarative pipeline dynamic stage names?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Declarative pipeline dynamic stage names?

Lyubomir Grigorov
Hello, 
Do you know if it is possible, for a declarative jenkins pipeline, to have stage names calculated dynamically, via usage of a variable for example? 
I have a pipeline, which initially had stages for prod and stages for dev. Different workers were assigned with static labels. I've changed the label calculation to be a dynamic one with the use of an variable. That allowed me to consolidate the prod and dev stages, so now my pipeline is a lot more clean and duplicate stuff was removed (any differences in the build steps for prod and dev are calculated dynamically in script blocks). 

So, the last thing I want to do is to have the stage names prefixed with Prod or Dev, depending on the build type (that come from a variable of course). But all my tries to name the stage like that, results in an error. Is that even possible? 

Thanks a lot for any input. 
Regards

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAAJRjxuxLP%3D4OotigpvQDiredrZQDFbWQrVVWujku42HuE3kxQ%40mail.gmail.com.
cw
Reply | Threaded
Open this post in threaded view
|

Re: Declarative pipeline dynamic stage names?

cw
Not sure about declarative pipelines, but I have it working in a scripted pipeline:

stage("Run log gather script on ${server}")

On Friday, May 8, 2020 at 8:10:02 AM UTC-4, Lyubomir Grigorov wrote:
Hello, 
Do you know if it is possible, for a declarative jenkins pipeline, to have stage names calculated dynamically, via usage of a variable for example? 
I have a pipeline, which initially had stages for prod and stages for dev. Different workers were assigned with static labels. I've changed the label calculation to be a dynamic one with the use of an variable. That allowed me to consolidate the prod and dev stages, so now my pipeline is a lot more clean and duplicate stuff was removed (any differences in the build steps for prod and dev are calculated dynamically in script blocks). 

So, the last thing I want to do is to have the stage names prefixed with Prod or Dev, depending on the build type (that come from a variable of course). But all my tries to name the stage like that, results in an error. Is that even possible? 

Thanks a lot for any input. 
Regards

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/23b63f3e-3d88-4712-af5b-8853d4b74174%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Declarative pipeline dynamic stage names?

Mark Waite-2
In reply to this post by Lyubomir Grigorov
I can't find any way to do that with declarative pipeline.

On Fri, May 8, 2020 at 6:09 AM Lyubomir Grigorov <[hidden email]> wrote:
Hello, 
Do you know if it is possible, for a declarative jenkins pipeline, to have stage names calculated dynamically, via usage of a variable for example? 
I have a pipeline, which initially had stages for prod and stages for dev. Different workers were assigned with static labels. I've changed the label calculation to be a dynamic one with the use of an variable. That allowed me to consolidate the prod and dev stages, so now my pipeline is a lot more clean and duplicate stuff was removed (any differences in the build steps for prod and dev are calculated dynamically in script blocks). 

So, the last thing I want to do is to have the stage names prefixed with Prod or Dev, depending on the build type (that come from a variable of course). But all my tries to name the stage like that, results in an error. Is that even possible? 

Thanks a lot for any input. 
Regards

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAAJRjxuxLP%3D4OotigpvQDiredrZQDFbWQrVVWujku42HuE3kxQ%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtEfHQBsH5BjAm0785r24MEio4TiKH7CNipkHGGQu%3D2%3D-A%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Declarative pipeline dynamic stage names?

debjyoti sarkar
In reply to this post by Lyubomir Grigorov
If you are passing the build type and storing it in a def variable you can use a where clause of a if else loop to verify the same. Have you tried it?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6f8a0ae9-25d8-4e9a-be12-33fea23e2e59%40googlegroups.com.