Jenkinsfile。Jenkinsfile: "RejectedAccessException: No such field found" in catch block: No
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Jenkinsfile。Jenkinsfile: "RejectedAccessException: No such field found" in catch block: No相关的知识,希望对你有一定的参考价值。
我正在尝试在我的Jenkins阶段代码中添加输入状态功能,但它却抛出了.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: RejectedAccessException: RejectedAccess。
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: No such field found:
我试着把这个块写成
catch (org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException e)
cause = e.causes.get(0)
echo "Aborted by " + cause.getUser().toString()
if (cause.getUser().toString() != 'SYSTEM')
startMillis = System.currentTimeMillis()
userAborted = true
else
endMillis = System.currentTimeMillis()
if (endMillis - startMillis >= timeoutMillis)
echo "Approval timed out. Aborting the deployment."
userAborted = true
else
echo "SYSTEM aborted, but looks like timeout period didn't complete. Aborting."
userAborted = true
但用这段代码,当我中止工作时,它被卡住了。
所以我修改了下面的代码:-
catch (Exception e)
cause = e.causes.get(0)
echo "Aborted by " + cause.getUser().toString()
if (cause.getUser().toString() != 'SYSTEM')
startMillis = System.currentTimeMillis()
userAborted = true
else
endMillis = System.currentTimeMillis()
if (endMillis - startMillis >= timeoutMillis)
echo "Approval timed out. Aborting the deployment."
userAborted = true
else
echo "SYSTEM aborted, but looks like timeout period didn't complete. Aborting."
userAborted = true
现在作业被中止时没有卡住,但当作业失败时又抛出了这个错误。
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: 没有找到这样的字段。
在检查了API的 RejectedAccessException
(发现 此处我认为问题在于 e.causes.get(0)
.
causes
不是一个领域的 RejectedAccessException
就像异常在告诉你,所以你显然无法访问它。
API提供的方法是 getCause()
从 java.lang.Throwable
可以使用的。
cause = e.getCause()
Btw getUser()
也不是异常的方法,会抛出同样的异常。
以上是关于Jenkinsfile。Jenkinsfile: "RejectedAccessException: No such field found" in catch block: No的主要内容,如果未能解决你的问题,请参考以下文章
Jenkinsfile/Groovy:为啥 curl 命令会导致“错误请求”
Jenkinsfile,“查找”,忽略一些隐藏目录和其他文件夹
Jenkinsfile。Jenkinsfile: "RejectedAccessException: No such field found" in catch block: No