nested each

34 views
Skip to first unread message

Jeremy Mordkoff

unread,
Feb 4, 2022, 3:18:46 PM2/4/22
to Abridged recipients
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
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.

Martin Schmude

unread,
Feb 5, 2022, 12:33:24 PM2/5/22
to Jenkins Users
In the past I ran into issues with pipeline scripts that did not behave as expected due to CPS transformation.
Try to annotate interesting_commit_check() with @NonCPS.

Ivan Fernandez Calvo

unread,
Feb 5, 2022, 5:09:06 PM2/5/22
to Jenkins Users
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. 
Reply all
Reply to author
Forward
0 new messages