title: Jenkins conditional parameters in bash script
body: <p>I have set up a Jenkins job to run a bash script <code>script.sh</code> every day.</p>
  
  <p>By default the script has to be run with no parameters so in Jenkins I added a String Parameter <code>PARAM</code> whose default value is empty and execute the script in the shell as</p>
  
  <pre><code>script.sh "$PARAM"
  </code></pre>
  
  <p>This way I can click on <code>Build with Parameters</code> add a string like <code>--param1=val1 --param2=val</code> and Jenkins would run the equivalent of:</p>
  
  <pre><code>script.sh --param1=val1 --param2=val
  </code></pre>
  
  <p>This works fine but then you have to remember all the possible parameters accepted by the script.</p>
  
  <p>I would like to know if I can set String Parameters PARAM1 and PARAM2 whose value is empty by default and having Jenkins fill with --param1=val1 when PARAM1 is set to val1.</p>
  
  <p>I know in the execute shell section I could write the command as:</p>
  
  <pre><code>script.sh $([ ! -z $PARAM1 ] &amp;&amp; echo "--param1=$PARAM1") \
            $([ ! -z $PARAM2 ] &amp;&amp; echo "--param2=$PARAM2")
  </code></pre>
  
  <p>but what I would really like to know is if there is some Jenkins plugin that could make this neater.</p>