How to throw an error if a parameter is empty?

40 views
Skip to first unread message

chencho m-a

unread,
Jul 31, 2020, 3:33:50 AM7/31/20
to Jenkins Users
Hi, 

I have some parameters and i would like to check if they are empty, and if so, dont start the build. 

Any clue?

Thank you

Haibinh Nguyen

unread,
Jul 31, 2020, 9:16:52 AM7/31/20
to jenkins...@googlegroups.com
Hi,
How about this:

env.FIELD1 = params.FIELD1
switch(FIELD1) {
case "ABCD":
env.p4 = '/usr/bin/p4'
env.awk = 'awk'
break
case ""::
currentBuild.result = 'SUCCESS'
return
break
> --
> 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/1c326abd-4cf2-44f3-9480-f1b9f85bcd70n%40googlegroups.com.

jeremy mordkoff

unread,
Jul 31, 2020, 9:28:03 AM7/31/20
to Jenkins Users
@Haibinh is that a bash answer? 
@chencho -- are you looking for a solution in bash, or groovy? Declarative or scripted? 





On Friday, July 31, 2020 at 9:16:52 AM UTC-4, Haibinh Nguyen wrote:
Hi,
How about this:

env.FIELD1  = params.FIELD1
switch(FIELD1) {
    case "ABCD":
                env.p4 = '/usr/bin/p4'
                env.awk = 'awk'
     break
     case ""::
               currentBuild.result = 'SUCCESS'
               return
     break
}


On Fri, Jul 31, 2020 at 12:34 AM chencho m-a <chen...@gmail.com> wrote:
>
> Hi,
>
> I have some parameters and i would like to check if they are empty, and if so, dont start the build.
>
> Any clue?
>
> Thank you
>
> --
> 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 jenkins...@googlegroups.com.

Sinh Lam

unread,
Jul 31, 2020, 9:47:53 AM7/31/20
to jenkins...@googlegroups.com, chencho m-a
You can try executing a basic script that exits 1 if the parameter is not defined (something like -z $parameter) as the first step in the build.  
--
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.

chencho m-a

unread,
Jul 31, 2020, 11:03:11 AM7/31/20
to Jenkins Users

What i want is that when you press the build button, a pop up or error at some point appears and stops the execution. 

I think that you need to overload the button in any way, but i dont know how to do it.

Baptiste Mathus

unread,
Aug 13, 2020, 5:39:40 AM8/13/20
to jenkins...@googlegroups.com
What you're describing exactly is not possible by default.

It /might/ be possible with custom development, but I would certainly not recommend it for such use case.

Reply all
Reply to author
Forward
0 new messages