title: Jenkins boolean parameter is always true in groovy
body: <p>I have a Jenkins job that calls a groovy script and the groovy script uses Jenkins parameters to do it's work. I can retrieve all the parameters without a problem except for a boolean parameter. The boolean parameter is a checkbox in Jenkins </p>
  
  <p><img src="https://i.stack.imgur.com/xSJh1.png" alt="unselected boolean parameter"></p>
  
  <p>I read the jenkins parameter into Groovy as follows:</p>
  
  <pre><code>boolean libraryBranch = config.get('library_branch_feature');
  </code></pre>
  
  <p>Now when I print the 'libraryBranch' variable </p>
  
  <pre><code>out.println "-- Library branch feature?: " + libraryBranch.toString();
  </code></pre>
  
  <p>I get the following printed line:</p>
  
  <blockquote>
    <p>-- Library branch feature ?: true</p>
  </blockquote>
  
  <p>So it doesn't matter if the boolean Jenkins parameter is selected or not I always have a boolean value 'true' in Groovy. All other (string) parameters inside the same job are read without a problem.</p>
  
  <p>Can someone help me with this issue?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Ok I've decided to try and retrieve the code in a couple of other ways and tyring to find a good solution:</p>
  
  <pre><code>Boolean libraryBranch = build.buildVariableResolver.resolve("library_branch_feature");
  String libraryBranchString = build.buildVariableResolver.resolve("library_branch_feature").toString();
  Boolean libraryBranchStringAsBoolean = build.buildVariableResolver.resolve("library_branch_feature") as Boolean;
  </code></pre>
  
  <p>The above variables are then printed:</p>
  
  <pre><code>out.println "-- Library branch feature?: " + libraryBranch;
  out.println "-- Library branch feature to String: " + libraryBranch.toString();
  out.println "-- Library branch feature to String: " + libraryBranch.toString();
  out.println "-- Library branch feature as String: " + libraryBranchString;
  out.println "-- Library branch feature String as Boolean: " + libraryBranchStringAsBoolean;
  </code></pre>
  
  <p>The output of the above prints are posted below:</p>
  
  <pre><code>-- Library branch feature?: true
  -- Library branch feature to String: true
  -- Library branch feature to String: true
  -- Library branch feature as String: false
  -- Library branch feature String as Boolean: true
  </code></pre>
  
  <p>So the only way thus far to have the boolean value read correctly as a false is by not turning it into a boolean at all but just reading it as a string and use it as a string.</p>
  
  <p>I would rather use it as a boolean though so any suggestions on the matter is still appreciated.</p>