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

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

问题描述

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

  [CompanyName]正在运行的shell脚本
+ ./ideainspect.groovy
env:groovy:没有这样的文件或目录

另外,我尝试安装Groovy插件,但由于某种原因,它不会安装。无论何时刷新工具页面,安装程序都会消失。我安装groovy错了吗?请帮助!

编辑:相关数据

  stage'静态分析'
node {
dir(Android / btMobileApp){
sh./ideainspect.groovy
sh./gradlew checkstyle lintDebug
}
}

并且ideainspect.groovy文件是一个可执行文件,其中包含#!/ usr / bin / env groovy ,这可能是问题所在。

解决方案

你的jenkins用户在其路上有时髦吗?如果这样沟渠shebang并尝试

'groovy ideainspect.groovy'



如果它不在路径上,您可以尝试

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


<安装)



或者使用Manage Jenkins - > Configure Systems将其添加到路径环境变量中。如果你有很多项目使用不同版本的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

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!

Edit: Relevant Data

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

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

解决方案

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

sh 'groovy ideainspect.groovy'

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

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

(or wherever groovy is installed)

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

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

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