Declarative pipeline dynamic stage names?

28 views
Skip to first unread message

Lyubomir Grigorov

unread,
May 8, 2020, 8:10:02 AM5/8/20
to jenkins...@googlegroups.com
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

cw

unread,
May 8, 2020, 8:55:29 AM5/8/20
to Jenkins Users
Not sure about declarative pipelines, but I have it working in a scripted pipeline:

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

Mark Waite

unread,
May 8, 2020, 5:28:48 PM5/8/20
to Jenkins Users
I can't find any way to do that with declarative pipeline.

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAAJRjxuxLP%3D4OotigpvQDiredrZQDFbWQrVVWujku42HuE3kxQ%40mail.gmail.com.

debjyoti sarkar

unread,
May 9, 2020, 1:13:04 AM5/9/20
to Jenkins Users
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?
Reply all
Reply to author
Forward
0 new messages