Setting a default value of a build parameter

10 views
Skip to first unread message

Will Newton

unread,
May 15, 2017, 6:12:02 AM5/15/17
to Jenkins Users

Hi,

I think I have a simple question but I am new to Jenkins so I'm not sure how best to solve it.

I have two parameters to my build (ghprbSourceBranch and ghprbActualCommit) one of which I want to use to name my build so I have the branch name in the build name, and one I use to select the actual commit to build. This works fine when called from the pull request builder. However I also want to be able to build the same job manually (Build With Parameters). I don't want to have to specify both parameters as this is error prone The end result of this is that I want to be able to name my job:

if ($ghprbSourceBranch != "")
  Build Name = job-${ghprbSourceBranch}
else
  Build Name = job-${ghprbActualCommit}

Is there a way to do this? I tired setting Build Name with POSIX shell substitution - ${ghprbSourceBranch:-$ghprbActualCommit} - but it didn't work.

Any help greatly appreciated, thanks!

Reply all
Reply to author
Forward
0 new messages