所以我现在正在 Jenkins 做种子工作,我遇到了这个错误
Processing DSL script testDSLAuto.groovy
FATAL: /pathto/weblogic-apps-auto.csv (No such file or directory)
java.io.FileNotFoundException: /pathto/weblogic-apps-auto.csv (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
我不太确定为什么会导致这样的错误。为了进行测试,我对文件执行了 chmod 777。它还找到了我的 .groovy 文件,该文件位于同一个工作区中,这很奇怪。我正在为 groovy 文件使用相对路径,并为 .csv 文件尝试了同样的事情。
我在运行作业时还执行了一个 shell 脚本,因此您可以在工作区中看到它。
+ pwd
/home/jenkins/workspace/Denver_Jenkins/SeedJob-CreateAutoBuilds
+ ls -l
total 32
-rwx------ 1 jenkins jenkins 6504 Jun 14 22:11 testDSLAuto.groovy
-rwxrwxrwx 1 jenkins jenkins 20496 Jun 14 20:00 weblogic-apps-auto.csv
最佳答案
问题是 groovy 脚本在主节点上搜索我的 .cvs 文件,而不是像 daggett 指出的那样在存储文件的远程工作区中搜索。我的解决方案是:
def file = readFileFromWorkspace('weblogic-apps-auto.csv')
file.splitEachLine(",")
{
fields ->
println "Evaluting .csv values: " + fields[0] + ", " + fields[1] + ", " + fields[2] +", " + fields[3];
}
关于java - Jenkins 种子作业(没有这样的文件或目录),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44555621/