I have a Jenkins job that calls a groovy script, and a groovy script uses Jenkins parameters to work it. I can get all parameters without problems except the boolean parameter. Boolean parameter is a flag in Jenkins

I read the jenkins parameter in groovy as follows:
boolean libraryBranch = config.get('library_branch_feature');
Now when I print the libraryBranch variable
out.println "-- Library branch feature?: " + libraryBranch.toString();
I get the following print string:
- Library branch function ?: true
Thus, it does not matter if the Jenkins boolean parameter is selected or not. I always have the boolean value "true" in Groovy. All other (string) parameters inside the same task are read without problems.
Can someone help me with this problem?
EDIT
Good. I decided to try and get the code in several other ways and with a tier to find a good solution:
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;
Then the following variables are output:
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;
The output of the above prints is posted below:
-- 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
Thus, the only way so far is to have the correct logical value as false, not to turn it into a logical one, but simply read it as a string and use it as a string.
I would prefer to use it as a logical one, although any suggestions on this are still appreciated.