Re: nested each

2022-02-05 Thread Ivan Fernandez Calvo
a return in a each is like a break in a loop exit from the current context 
with a return value but only one each context, you have two each context 
levels. 

El sábado, 5 de febrero de 2022 a las 18:33:24 UTC+1, Martin Schmude 
escribió:

> In the past I ran into issues with pipeline scripts that did not behave as 
> expected due to CPS transformation.
> See https://www.jenkins.io/doc/book/pipeline/cps-method-mismatches/
>
> https://www.jenkins.io/doc/book/pipeline/pipeline-best-practices/#using-noncps
> Try to annotate interesting_commit_check() with @NonCPS.
>
> jeremy@dzsi.com schrieb am Freitag, 4. Februar 2022 um 21:18:46 UTC+1:
>
>> what's wrong with this code? The output from it was 
>>
>> [Pipeline] echo 
>> [modules/core/rwvx,
>>  modules/automation/core, modules/tools/scripts, modules/toolchain, 
>> modules/tools/CI, modules/core/util, modules/im/platform][Pipeline] echo 
>> (modules/core/rwvx|modules/automation/core|modules/tools/scripts|modules/toolchain|modules/tools/CI|modules/core/util|modules/im/platform).*[Pipeline]
>>  echo 
>> file:
>>  "modules/im/platform"[Pipeline] echo 
>> interesting
>>  submodule change: modules/im/platform[Pipeline] echo 
>> no
>>  interesting commits found.
>>
>>
>> which implies that the "return true" was ignored 
>>
>>
>>
>> def interesting_commit_check(topmodule) { 
>> // returns true if any interesting commits are found
>> modules=get_dependency_list(topmodule)
>> modules_re = "(" + modules.join('|') + ").*"
>> println("${modules_re}")
>> currentBuild.changeSets.each {
>> it.items.each {
>> it.affectedFiles.each {
>> pth = it.getPath()
>> println("file: \"${pth}\"")
>> if (it.getPath().matches('^modules.*')) {
>> // in a submodule ... is it an important one?
>> if (pth.matches(modules_re)) {
>> print("interesting submodule change: ${pth}")
>> return true
>> } else {
>> print("ignoring submodule change in ${pth}") 
>> 
>>  
>> }
>> } else {
>> if ( pth == "RELEASE" ) {
>> println("ignoring release change")
>> } else {
>> print("ignoring supermod change: ${pth}")
>> }
>> }
>> }
>> }
>> }
>> print("no interesting commits found.")
>> return false
>> }
>>
>> *Jeremy Mordkoff*
>> Director, Engineering Services
>> 
>>
>> *Headquarters: 5700 Tennyson Parkway, Plano, Texas, USA *
>> *Mobile*: +1 978.257.2183 <(978)%20257-2183>
>> *Email: *jeremy@dzsi.com
>>
>> 
>>
>>  
>>  
>> 
>>
>>
>> *Disclaimer*
>>
>> The information contained in this communication from the sender is 
>> confidential. It is intended solely for use by the recipient and others 
>> authorized to receive it. If you are not the recipient, you are hereby 
>> notified that any disclosure, copying, distribution or taking action in 
>> relation of the contents of this information is strictly prohibited and may 
>> be unlawful.
>>
>>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/032587b3-daf2-4e56-9ea8-be2835d63375n%40googlegroups.com.


Re: nested each

2022-02-05 Thread 'Martin Schmude' via Jenkins Users
In the past I ran into issues with pipeline scripts that did not behave as 
expected due to CPS transformation.
See https://www.jenkins.io/doc/book/pipeline/cps-method-mismatches/
https://www.jenkins.io/doc/book/pipeline/pipeline-best-practices/#using-noncps
Try to annotate interesting_commit_check() with @NonCPS.

jeremy@dzsi.com schrieb am Freitag, 4. Februar 2022 um 21:18:46 UTC+1:

> what's wrong with this code? The output from it was 
>
> [Pipeline] echo 
> [modules/core/rwvx,
>  modules/automation/core, modules/tools/scripts, modules/toolchain, 
> modules/tools/CI, modules/core/util, modules/im/platform][Pipeline] echo 
> (modules/core/rwvx|modules/automation/core|modules/tools/scripts|modules/toolchain|modules/tools/CI|modules/core/util|modules/im/platform).*[Pipeline]
>  echo 
> file:
>  "modules/im/platform"[Pipeline] echo 
> interesting
>  submodule change: modules/im/platform[Pipeline] echo 
> no
>  interesting commits found.
>
>
> which implies that the "return true" was ignored 
>
>
>
> def interesting_commit_check(topmodule) { 
> // returns true if any interesting commits are found
> modules=get_dependency_list(topmodule)
> modules_re = "(" + modules.join('|') + ").*"
> println("${modules_re}")
> currentBuild.changeSets.each {
> it.items.each {
> it.affectedFiles.each {
> pth = it.getPath()
> println("file: \"${pth}\"")
> if (it.getPath().matches('^modules.*')) {
> // in a submodule ... is it an important one?
> if (pth.matches(modules_re)) {
> print("interesting submodule change: ${pth}")
> return true
> } else {
> print("ignoring submodule change in ${pth}")   
> 
>
> }
> } else {
> if ( pth == "RELEASE" ) {
> println("ignoring release change")
> } else {
> print("ignoring supermod change: ${pth}")
> }
> }
> }
> }
> }
> print("no interesting commits found.")
> return false
> }
>
> *Jeremy Mordkoff*
> Director, Engineering Services
> 
>
> *Headquarters: 5700 Tennyson Parkway, Plano, Texas, USA *
> *Mobile*: +1 978.257.2183 <(978)%20257-2183>
> *Email: *jeremy@dzsi.com
>
> 
>
>  
>  
> 
>
>
> *Disclaimer*
>
> The information contained in this communication from the sender is 
> confidential. It is intended solely for use by the recipient and others 
> authorized to receive it. If you are not the recipient, you are hereby 
> notified that any disclosure, copying, distribution or taking action in 
> relation of the contents of this information is strictly prohibited and may 
> be unlawful.
>
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c59ec0ed-d858-4285-9b1b-469f3d36cc51n%40googlegroups.com.