Skip all stages in jenkins declarative pipeline based on parameter value

718 views
Skip to first unread message

Umesha A

unread,
Oct 12, 2022, 5:11:52 AM10/12/22
to Jenkins Users
Hi 

   Is it possible to skip all stages of a declarative pipeline if a parameter value is not set ?
Appreciate any pointers and help.

Thanks & Regards,
Umesh

Chetan

unread,
Oct 12, 2022, 5:53:56 AM10/12/22
to jenkins...@googlegroups.com
Hi Umesh,

Hope below syntax works. but you need to add this to all stages. 

stage ('Stage1') {
    when { environment name: 'ENV_VARIABLE'}
    steps {
        echo "Start Stage1"
    }
}


Thanks
Chetan B


--
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/f28bf765-cbe7-4525-a2c2-68863debafcfn%40googlegroups.com.

pooja pooja

unread,
Oct 13, 2022, 1:57:35 AM10/13/22
to jenkins...@googlegroups.com
Hi,
while deploying manually by using gitlab/github credentials code was deployed correctly,
whenever am using jenkins pipeline credentials taking properly but code was no deploying on server
Error:fatal : could not read username for 'https://github.com': no such device or address


Koray Incki

unread,
Oct 13, 2022, 2:00:05 AM10/13/22
to jenkins...@googlegroups.com
alternatively, you can write your all stages inside a filename.groovy file, and load it in the Jenkinsfile; where you would check for a parameter value for only once



--
Koray Incki, PhD
twit: @korayincki

"It is quality rather than quantity that matters"
Lucius Annaeus Seneca





Reply all
Reply to author
Forward
0 new messages