David Dennis
David Dennis

Reputation: 722

Jenkins seed job (No such file or directory)

So i'm working on a seed job in Jenkins right now and i'm getting this error

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)

I'm not really sure why such an error would be caused. For testing I did a chmod 777 on the file. It also is finding my .groovy file which is in the same workspace which is strange. I am using a relative path for the groovy file and tried the same thing for the .csv file.

I also executed a shell script when I run my job so you can see it is in the workspace.

+ 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 

Upvotes: 1

Views: 2219

Answers (2)

David Dennis
David Dennis

Reputation: 722

The problem was the groovy script was searching for my .cvs file on the master node instead of my remote workspace where the file was stored as pointed out by daggett. My solution for this was:

def file = readFileFromWorkspace('weblogic-apps-auto.csv')
file.splitEachLine(",")
{
    fields ->
        println "Evaluting .csv values: " + fields[0] + ", " + fields[1] + ", " + fields[2] +", " + fields[3];
}

Upvotes: 4

daggett
daggett

Reputation: 28564

your testDSLAuto.groovy called as a java process that has own current directory.

normally it's a workspace directory. but better to check with this code:

def currentDir = new File(".").getAbsolutePath()
println currentDir

then you should define relative path to csv file based on current dir path.

Upvotes: 2

Related Questions