Details
-
Improvement
-
Status: Resolved (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
Description
Consider the following workflow script:
echo "bool=$bool"
echo bool.getClass().toString()
Output:
Started by user Jos Backus
Running: Print Message
bool=false
Running: Print Message
class java.lang.String
Running: End of Workflow
Finished: SUCCESS
I would expect the name of the class to be java.lang.Boolean, not java.lang.String. This forces one to add lines such as:
bool = bool == 'true'
Attachments
Issue Links
- is blocking
-
JENKINS-27413 Handle file parameters
-
- Resolved
-
- is duplicated by
-
JENKINS-27388 Build parameters are injected as typeless strings into workflow script
-
- Resolved
-
- is related to
-
JENKINS-29952 Allow access to environment variables as Groovy variables
-
- Resolved
-
-
JENKINS-30519 Declarative job properties in multibranch
-
- Resolved
-
-
JENKINS-34101 Option for input parameters to be flattened to string
-
- Open
-
-
JENKINS-35698 Initial run of parameterized pipeline build should return properties default value
-
- Resolved
-
- links to
Thank you for the explanation. I understand now: global variables initialized by environment variables cannot change their type when a new value is assigned. In former plugin versions they could change e.g. from string to boolean. Now I have to assign the boolean to a different variable. Otherwise the boolean type would be ignored.
I can live with that change, but it was a bit confusing, because within the Groovy script one cannot distinguish between a global variable and an unqualified parameter. The difference becomes clear only within the context of the pipeline configuration.