Checking if params.FOO is undefined

20 views
Skip to first unread message

jbr...@snapapp.com

unread,
Oct 19, 2017, 12:24:23 PM10/19/17
to Jenkins Users
Hi all,

Let's say I have a Jenkinsfile for a job that is normally built with Build Parameters, and so has params.FOO in it. Then let's say that I want to also be able to automatically build this using a  ultibranch pipeline job. Obviously, params.FOO will be undefined, causing the job to fail; is it possible to write the Jenkinsfile to check if a variable is undefined?

Thanks!
Jack

Robert Hales

unread,
Oct 19, 2017, 3:59:41 PM10/19/17
to Jenkins Users
There are a lot of different ways to do this, but it depends on how your pipeline script is written, whether you are using declarative or scripted pipeline, what do you want to do when it is null vs. not. In a scripted pipeline this is a basic programming question: 

if (params.FOO) {

} else {
Reply all
Reply to author
Forward
0 new messages