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
As you can see, Jenkins finds it without any issues:
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
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:
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:
Unfortunately, that didn't work either -- also, Jenkins didn't expand its WORKSPACE
environment variable:
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!
${WORKSPACE}
won't work because there isn't a workspace until a build is actually running. In other words, there is no workspace when just scanning for repos/branches in a Multibranch Pipeline folder.