获取java.lang.arayindexoutofboundsexception误差
我在java.lang.lang.lang.arayindexoutofboundsexception
groovy中的错误。
stage('Calculate Opatch size') {
def files = findFiles(glob: '${BuildPathPublishRoot}\\30293915.*.zip')
echo """${files[0].length}"""
}
以下是日志:
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod.invoke(ObjectArrayGetAtMetaMethod.java:41)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
有人可以帮助我理解错误并修复错误。
I am getting java.lang.ArrayIndexOutOfBoundsException
error in groovy while running below code.
stage('Calculate Opatch size') {
def files = findFiles(glob: '${BuildPathPublishRoot}\\30293915.*.zip')
echo """${files[0].length}"""
}
Below is the log:
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod.invoke(ObjectArrayGetAtMetaMethod.java:41)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
Can someone help me to understand the error and fix it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您执行的唯一数组索引访问是
文件[0]
。正如例外告诉您的那样,您的数组具有长度0,因此您会遇到错误。也许在访问之前添加空检查?The only array index access you do is in
files[0]
. As the Exception tells you, your array has the length 0, hence you get the error. Maybe add an empty check before accessing it?您的Findfiles不会返回数组,因此没有文件[0]!
Your findFiles does not return an array, so there is no files[0]!
是的是文件[0]。但是我在另一个上下文中收到了此错误消息,当使用默认为传统管道的jenkinsfile模板中的多班式管道时,
此处的错误消息来自env.git_branch,该消息在乘坐乘坐一个空管道中是空/null。
在多支管线上,同一行是:
Yes it's files[0]. But I got this error message in another context, when using Multibranch pipeline from our Jenkinsfile template that defaults to traditional pipeline, and has
Over here the error message comes from env.GIT_BRANCH which is empty/null in multibranch pipeline.
On a multibranch pipeline the same row is: