Simon I
Simon I

Reputation: 3586

Jenkins pipeline - No such file or directory when trying to load external groovy file

I have a Jenkinfile that looks like:

node {

def rootDir = pwd()

def externalMethod = load("${rootDir}/ci/jenkins/shops.groovy")

// Call the method we defined in externalMethod.
externalMethod.lookAtThis("Simon")

}

And another file at ci/jenkins/shops.groovy

def lookAtThis(String whoAreYou) {
    echo "Look at this, ${whoAreYou}! You loaded this from another file!"
}

But Jenkins is returning the error

java.io.IOException: java.io.FileNotFoundException: /root/workspace/lush-global-soa-architecture/develop/ci/jenkins/shops.groovy (No such file or directory)

I'm not sure why it can't find this file.

Upvotes: 3

Views: 4718

Answers (1)

Simon I
Simon I

Reputation: 3586

I got it working, turns out I needed to checkout scm before I could load the file.

checkout scm

Upvotes: 2

Related Questions