json - Windows Jenkins master 无法在 Linux 代理上正确执行作业
问题描述
我有一个 Jenkins 安装,其中主机是 Windows 机器,它的一个代理在 Linux 上运行。我需要在 Linux 上显式运行一项作业,但是当 Jenkins 调用管道外部的方法时,它认为该方法应该在主(Windows)机器上执行,因此我看到了错误。
'''
node ('Linux Machine'){ // I specified that this should be run on Linux
slurper = new JsonSlurper().parse ('my_file_on_linux') //all is good
builder = new JsonBuilder (slurper) // use builder to modify my JSON file
builder.context.module = modifyModule ()
}
@NonCPS
def modifyModule () {
new File(workspace).eachFileRecurse(FILES){ // workspace here is WINDOWS JENKINS MASTER ROOT DIRECTORY :( Exception
// search for some files...
}
}
'''
错误是(注意其将 Linux 路径(/bigdisk0/jenkins/workspace/... 转换为 Windows 格式):java.io.FileNotFoundException: D:\bigdisk0\jenkins\workspace\consul-devcoreserver\MyModule at org.codehaus.groovy .runtime.ResourceGroovyMethods.checkDir(ResourceGroovyMethods.java:1043) at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:1122) at org.codehaus.groovy.runtime.dgm$942.doMethodInvoke(Unknown Source) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) 在 groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) 在 org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:47)
解决方案
推荐阅读
- c# - odata 格式 xml 或 json 不起作用
- angular - 在Angular 5中使用无组件路由路由到子节点时的意外行为
- java - 保存 ScrollView 位置
- android - 通过 Data 类发送类对象
- javascript - Ember 无法将参数传递给操作
- c# - 无法加载文件或程序集“CopyModules.dll”或其依赖项之一。指定的模块无法找到
- oracle - 创建视图但收到警告:已编译但在 oracle 中出现编译错误
- php - laravel刀片内jquery中asset()内的变量抛出错误
- swift - Firebase 事件中的自定义事件数据
- c++ - C++ 标准提案代码:什么是 N 和 P?