Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I perform if/else operations in a jenkins workflow build?

I'm sure there's an easy answer for this but I was unable to find it elsewhere.

I have a Jenkins workflow job with parameters. What I want is to skip a build job depending on the value of a parameter. Something like:

if(param["MYPARAM"]){
    build("jorb1")
}
build("jorb2")

Does anyone know how I'd accomplish this?

like image 455
codeflayer Avatar asked Nov 07 '13 18:11

codeflayer


1 Answers

Turns out the answer is really easy. Hopefully this will help someone else. If statements do work in the DSL configuration. I guess its based on groovy (which I have zero experience with). Anyway my guess was just about right other than specifying the params incorrectly. Below is an example of checking a string parameter:

if(params["MYPARAM"]=="some_value"){
    build("jorb1")
}
build("jorb2")
like image 157
codeflayer Avatar answered Oct 12 '22 20:10

codeflayer