Calling shell commands in groovy script, used in Jenkins pipeline

落花浮王杯 提交于 2019-12-02 07:31:11

You should not treat Jenkins Pipeline Groovy as regular Groovy code. All Pipeline Groovy (as of right now) is always executed on the Jenkins master. .execute() will never execute where you expect it to, Jenkins script security restrictions will block you, and CPS transformation Groovy engine on Jenkins are all reasons to not expect to be able to use the full Groovy language in pipeline code.

Here is a relevant post from Google Groups by Stephen Connolly:

Pipeline is NOT groovy.

It is a CPS engine built on top of Groovy... it may look like Groovy, it may even sometimes walk and quack like Groovy, but your life will be infinitely better if you just accept that it is NOT Groovy.

Global Shared Libraries is where you go if you want to write idiomatic Groovy, and even there you can hit issues unless you truly understand the CPS magic and its full implications.

Use pipeline as a final orchestration glue layer and your life will be much easier

I recommend you read that entire thread as it should demonstrate that you should not treat the Pipeline code as normal Groovy code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!