Opened JENKINS-26307 <https://issues.jenkins-ci.org/browse/JENKINS-26307> 
for this.

On Tuesday, January 6, 2015 5:19:11 AM UTC-5, Thomas Goeppel wrote:
>
> Kenneth,
>
> CPS doesn't always behave like a Groovy programmer would expect. 
> Obviously, there is a price to pay for the double nature of CPS as a job 
> description, and scripting language (*README.md refers to this as 
> "continuation passing style* transformation of the script").
>
> However, List.find seems to return the first result of the closure (in 
> your case 'false'), and this is plain wrong. Yes, I would file a bug. 
> Either this should work, or 'find' shouldn't be part of CPS.
>
> Best,
> Thomas
>
> On Tuesday, January 6, 2015 2:10:15 AM UTC+1, Kenneth Baltrinic wrote:
>>
>> I am trying to do a very simple file parse operation within a Jenkins 
>> workflow script and getting some very bizarre results.  This is with the 
>> workflow 1.1 set of plugins and Jenkins 1.596.  
>>
>> To demonstrate the issue I created a new workflow job with the following 
>> script:
>>
>>
>>
>>
>>
>>
>> *def str="1:one|2:two|3:three"def i = "2"def opts = str.split(/\|/)def 
>> opt = opts.find { o -> o.contains("${i}:") }echo "len: ${opts.length}"echo 
>> "opt: ${opt}"*
>>
>> The output of which is 
>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> *Started by user anonymous <http://192.168.33.36:8080/user/null>Running: 
>>> Print Messagelen: 3Running: Print Messageopt: falseRunning: End of 
>>> WorkflowFinished: SUCCESS*
>>
>>
>> However, running effectively the same script in the Jenkins script 
>> console (or any other groovy environment I have tried) produces the 
>> expected result:
>>
>>
>>
>>
>>
>>
>> *def str="1:one|2:two|3:three"def i = "2"def opts = str.split(/\|/)def 
>> opt = opts.find { o -> o.contains("${i}:") }println "len: 
>> ${opts.length}"println "opt: ${opt}"*
>>
>> returns:
>>
>>
>>> *len: 3**opt: 2:two*
>>
>>
>> Am I missing something really obvious or should I open a bug report for 
>> this?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/31b85b47-b93e-483d-b882-39f0a4c62c23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to