Jenkins having trouble finding JenkinsFile from SCM

11,804

Solution 1

I think you named it wrong due to your mentioned filename in the question.

The script was searched in the root for your project and should be called Jenkinsfile instead of JenkinsFile.

So name the file correctly and move it into the root of your Repository.

Solution 2

For me, Docker was renaming my 'Jenkinsfile' to 'jenkinsfile' when cloning the repo into the docker container.

The solution was to change the location of the Jenkinsfile in jenkins pipeline settings to all lowercase 'jenkins'

Share:
11,804
user3029642
Author by

user3029642

Updated on June 21, 2022

Comments

  • user3029642
    user3029642 almost 2 years

    I'm in the process of migrating an old Jenkins build to the new declarative pipeline. Now that I have the build up and running, I need to get the JenkinsFile from git (rather than leaving it in the Jenkins window). The issue is that Jenkins gets the file from Git, but then looks for it in the wrong location after it's pulled. This is the configuration:

    enter image description here

    This is the message I get in the Jenkins log:

    Checking out git https://github.com/xxx/xxx_dev.git to read Jenkinsfile
     > git rev-parse --is-inside-work-tree # timeout=10
    Fetching changes from the remote Git repository
     > git config remote.origin.url https://github.com/xxx/xxx_dev.git # timeout=10
    Fetching upstream changes from https://github.com/xxx/xxx_dev.git
     > git --version # timeout=10
    using GIT_ASKPASS to set credentials xxx Build
     > git fetch --tags --progress https://github.com/xxx/xxx_dev.git +refs/heads/*:refs/remotes/origin/*
     > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
     > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
    Checking out Revision 43bd167e0e222fb517a8deb5ce6c6c6ba3619153 (refs/remotes/origin/master)
     > git config core.sparsecheckout # timeout=10
     > git checkout -f 43bd167e0e222fb517a8deb5ce6c6c6ba3619153
     > git rev-list 82e6fdcce2587aa6368d63449ac57c9f02a1f835 # timeout=10
    ERROR: /u03/jenkins/jobs/xxx/jobs/Build_Main/jobs/vs2015/workspace@script/Jenkinsfile not found
    Finished: FAILURE
    

    It seems that the build agent is looking for the Jenkins file in a location on the main Jenkins server machine. The build machine is a windows machine, so /u03/jenkins/jobs/xxx/jobs/Build_Main/jobs/vs2015/workspace@script/Jenkinsfile makes no sense. Does anyone know what's going on here?

    Thank!