Michael
Michael

Reputation: 1134

Jenkins pipeline groovy odd behavior

I have a groovy pipeline script:

stage("Test") {
    str="[\"asd1\", \"asd2\"]"
    def tagNames = str.tokenize(',[]').collect { it as String }
    echo "${tagNames.getClass()}"
    echo "${tagNames.size}"
}

But on the output I see error "No such field found: field java.lang.String size":

[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] echo
class java.util.ArrayList
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
No such field found: field java.lang.String size. Administrators can decide whether to approve or reject this signature.
[Pipeline] End of Pipeline

What I'm doing wrong?

Edit: I have "No pending signature approvals."

Upvotes: 3

Views: 6960

Answers (1)

Michael
Michael

Reputation: 1134

Using

size()

instead of

size

does the trick.

Upvotes: 9

Related Questions