1

I am using a Jenkins Multibranch pipeline -- specifically, an Organization folder, which monitors all my Bitbucket repos and builds a pipeline for any repo containing a Jenkinsfile. For simplicity, I have configured it to look at only 1 of my repos for now.

Here's my problem:

When the Jenkinsfile is located in the root folder of my repo, everything works fine -- Jenkins sees the Jenkinsfile, and creates the pipeline as defined in that Jenkinsfile.

repo
|
|___> Jenkinsfile

Screenshot: Jenkins configured to look for Jenkinsfile in root folder

As you can see, Jenkins finds it without any issues: Screenshot: Jenkins finds Jenkinsfile in root folder


However, I want to move the Jenkinsfile to a subfolder in my repo (giving me the flexibility to have multiple pipelines defined for 1 repo). When I move it to a subfolder (jenkins/ci-pipeline/Jenkinsfile), even though I explicitly give that relative file path to Jenkins, it can no longer find the Jenkinsfile!!

repo
|
|___> jenkins
       |
       |___> ci-pipeline
              |
              |___> Jenkinsfile

Screenshot: Jenkins configured to look for Jenkinsfile in subfolder

As you can see, despite giving the relative file path (jenkins/ci-pipeline/Jenkinsfile) to Jenkins, it claims it can no longer find the Jenkinsfile:
Screenshot: Jenkins cannot find Jenkinsfile in subfolder

Incidentally, even though the description of that Jenkins field says it is the "relative location", I tried to give it an absolute file path (${WORKSPACE}/jenkins/ci-pipeline/Jenkinsfile) instead to see if that would work:
Screenshot: Jenkins configured with absolute path of subfolder

Unfortunately, that didn't work either -- also, Jenkins didn't expand its WORKSPACE environment variable:
Screenshot: Jenkins cannot find Jenkinsfile in subfolder, even with absolute path

I have also logged into my Jenkins worker node and confirmed that the Jenkinsfile is present in that subfolder, within the Jenkins workspace for my repo.


Can someone please tell me what I'm doing wrong?? This seems very simple, but it just refuses to work and it's driving me nuts!

4
  • If you setup a multibranch on a Jenkinsfile and you moved it to jenkins/ci-pipeline/Jenkinsfile, on which branch did you moved it? F.e. if your multibranch is now building 50+ jobs and you moved that file on 1 branch (development) and reconfigured Jenkins to check the new path, the other 49 branches will not find that Jenkinsfile unless you merge your changes. It can be tricky to see this when you already have multiple jobs running. jenkins/ci-pipeline/Jenkinsfile should work, it's case sensitive if I'm right.. Commented Aug 7, 2019 at 19:31
  • For simplicity, all this is being done on the same one branch -- all the screenshots above are from the same branch. So, on the same branch, it works when the Jenkinsfile is in the root folder, but fails when it is moved to a subfolder.
    – Seth
    Commented Aug 7, 2019 at 19:36
  • 1
    When I try the same (moving from root to subfolder as you suggested jenkins/ci-pipeline/Jenkinsfile) and configured the script path to the new location and scan again, it runs fine. Same settings as you shared (without ${WORKSPACE}). So there's nothing wrong with your syntax. Are you running the latest Jenkins version + plugins (Bitbucket Branch Source Plugin)? issues.jenkins-ci.org/browse/JENKINS-49261 Commented Aug 7, 2019 at 20:06
  • @Unforgettable631 Thanks for that bug link! Unfortunately, I'm running this in a corporate environment, so I don't think I have the access to check what version of that plugin we are running -- I'll see if I can hunt down someone who does have that access though, and report back here.
    – Seth
    Commented Aug 7, 2019 at 20:30

1 Answer 1

0

As suggested by @Unforgettable631, this appears to be caused by the fact that I have an outdated version of the Bitbucket Branch Source Plugin (2.2.9). As mentioned in https://issues.jenkins-ci.org/browse/JENKINS-49261, that version of the plugin has a bug where it cannot find the Jenkinsfile if it is in a subfolder.

Not the answer you're looking for? Browse other questions tagged or ask your own question.