Given an input of:
/data/ci/jenkins/workspace/PeterBLaboratory/Test-unittestlibobjs-10/somesubdir/somefile.txt

I have a function:


    def basename(path){
        def pieces

        pieces = path.split("/")

        context.sh 'echo first element: ' + pieces[0]
        context.sh 'echo path: ' + path
        context.sh 'echo parts: ' + pieces.size

        def idx
        idx = pieces.size - 1

        return pieces[idx]
    }

and I expect it to return the last element in a split array based on the
character '/'

What I'm seeing instead is:

groovy.lang.MissingPropertyException: Exception evaluating property
'size' for java.util.Arrays$ArrayList, Reason:
groovy.lang.MissingPropertyException: No such property: size for
class: java.lang.String


what the heck is going on here?

It also looks like path.split is not behaving as I'd expect and returning
an array of strings based on the delimiter. Thoughts folks?

-- 
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/CAArvnv3AbsixuXJ14epdqLOJFg5hspnwiCuDCAvyLx61dxLwRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to