简体   繁体   English

Jenkins Multibranch管道无法在子文件夹中找到Jenkinsfile

[英]Jenkins Multibranch pipeline cannot find Jenkinsfile in subfolder

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. 我正在使用Jenkins Multibranch管道-具体来说是一个Organization文件夹,该文件夹监视我的所有Bitbucket仓库并为包含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. 当Jenkinsfile位于我的仓库的根文件夹中时,一切正常-Jenkins看到Jenkinsfile,并创建该Jenkinsfile中定义的管道。

repo
|
|___> Jenkinsfile

屏幕截图:Jenkins配置为在根文件夹中查找Jenkinsfile

As you can see, Jenkins finds it without any issues: 如您所见,詹金斯发现它没有任何问题: 屏幕截图:Jenkins在根文件夹中找到Jenkinsfile


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). 但是,我想将Jenkinsfile移动到我的仓库中的子文件夹中(这使我可以灵活地为1个仓库定义多个管道)。 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!! 当我将其移动到子文件夹( jenkins/ci-pipeline/Jenkinsfile )时,即使我将相对文件路径明确地提供给Jenkins,它也无法找到Jenkinsfile!

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

屏幕截图:Jenkins配置为在子文件夹中查找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: 如您所见,尽管为Jenkins提供了相对文件路径( jenkins/ci-pipeline/Jenkinsfile ),但它声称无法再找到Jenkinsfile:
屏幕截图:Jenkins在子文件夹中找不到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: 顺便说一句,即使对该Jenkins字段的描述说它是“相对位置”,我还是尝试给它一个绝对文件路径( ${WORKSPACE}/jenkins/ci-pipeline/Jenkinsfile )来看看是否可行:
屏幕截图:Jenkins配置了子文件夹的绝对路径

Unfortunately, that didn't work either -- also, Jenkins didn't expand its WORKSPACE environment variable: 不幸的是,这也不起作用-而且,詹金斯也没有扩展其WORKSPACE环境变量:
屏幕截图:即使具有绝对路径,Jenkins也无法在子文件夹中找到Jenkinsfile

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. 我还登录了我的Jenkins worker节点,并确认Jenkinsfile存在于我的仓库的Jenkins工作区中的该子文件夹中。


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! 这似乎很简单,但是它只是拒绝工作,这让我发疯了!

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). 正如@ Unforgettable631所建议的那样,这似乎是由于我的Bitbucket分支源插件(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. https://issues.jenkins-ci.org/browse/JENKINS-49261中所述 ,该版本的插件存在一个错误,即如果它位于子文件夹中,则找不到Jenkinsfile。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM