为什么 groovy 不能在 Jenkins 管道中运行? [英] Why won't groovy run in Jenkins pipeline?

查看:22
本文介绍了为什么 groovy 不能在 Jenkins 管道中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正试图从我的管道中运行一个 groovy 脚本作为我的节点之一,但我遇到了这个错误:

I am currently trying to run a groovy script from my pipeline as one of my nodes, but I ran into this error:

[CompanyName] Running shell script
+ ./ideainspect.groovy
env: groovy: No such file or directory

另外,我尝试为 groovy 安装插件,但由于某种原因,它无法安装.每当我刷新工具页面时,安装程​​序就会消失.我安装groovy错了吗?请帮忙!

Also, I tried installing the plugin for groovy, but for some reason, it won't install. Whenever I refresh the page for tools, the installer goes away. Am I installing groovy wrong? Please help!

相关数据

stage 'Static Analysis'
node {
    dir("Android/btMobileApp") {
        sh "./ideainspect.groovy"
        sh "./gradlew checkstyle lintDebug"
    }
}

ideainspect.groovy 文件是带有 shebang #!/usr/bin/env groovy 的可执行文件,这可能是问题所在.

And the ideainspect.groovy file is an executable with the shebang #!/usr/bin/env groovy, which could be the problem.

推荐答案

你的 jenkins 用户有 groovy 吗?如果是这样,放弃shebang并尝试

Does your jenkins user have groovy on its path? If so ditch the shebang and try

sh 'groovy ideainspect.groovy'

sh 'groovy ideainspect.groovy'

如果不在路径上,可以试试

If it's not on the path, you can try

sh '/usr/bin/groovy ideainspect.groovy'

sh '/usr/bin/groovy ideainspect.groovy'

(或安装 groovy 的任何地方)

(or wherever groovy is installed)

或者使用 Manage Jenkins -> Configure Systems 将其添加到路径环境变量中.如果您有很多项目使用不同版本的 groovy,这可能不合适

Or alternatively add it to the path environment variable using Manage Jenkins -> Configure Systems. This may not be appropriate if you have lots of projects using different versions of groovy

这篇关于为什么 groovy 不能在 Jenkins 管道中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆