首页 > 解决方案 > 詹金斯管道常规的奇怪行为

问题描述

我有一个 groovy 管道脚本:

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

但是在输出中我看到错误“找不到这样的字段:字段 java.lang.String 大小”:

[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

我做错了什么?

编辑:我有“没有待处理的签名批准”。

标签: jenkins-pipelinejenkins-groovy

解决方案


使用

size()

代替

size

成功了。


推荐阅读