如果jenkinsfile不存在,Bitbucket分支源插件将无法扫描

时间:2019-07-04 13:13:23

标签: jenkins plugins bitbucket cloudbees bitbucket-pipelines

我已经设置了Bitbucket团队项目来扫描组织文件夹并创建管道,但是在没有Jenkinsfile的情况下,这项工作会失败

Checking branch master from UKCEP/amatch-acceptance
ERROR: [Thu Jul 04 12:59:03 UTC 2019] Could not fetch sources from navigator com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator@53f18bdb
java.io.IOException: Communication error for url: Jenkinsfile status code: 401
    at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.checkPathExists(BitbucketServerAPIClient.java:478)
    at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource$BitbucketProbeFactory$1.exists(BitbucketSCMSource.java:1478)
    at jenkins.scm.api.SCMSourceCriteria$Probe.stat(SCMSourceCriteria.java:99)
    at org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory$1.isHead(WorkflowBranchProjectFactory.java:74)
    at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:342)
    at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieveBranches(BitbucketSCMSource.java:748)
    at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:589)
    at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
    at jenkins.scm.api.SCMSource.fetch(SCMSource.java:327)
    at jenkins.branch.MultiBranchProjectFactory$BySCMSourceCriteria.recognizes(MultiBranchProjectFactory.java:263)
    at jenkins.branch.OrganizationFolder$SCMSourceObserverImpl$1.recognizes(OrganizationFolder.java:1404)
    at jenkins.branch.OrganizationFolder$SCMSourceObserverImpl$1.complete(OrganizationFolder.java:1419)
    at jenkins.scm.api.trait.SCMNavigatorRequest.process(SCMNavigatorRequest.java:254)
    at jenkins.scm.api.trait.SCMNavigatorRequest.process(SCMNavigatorRequest.java:204)
    at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator.visitSources(BitbucketSCMNavigator.java:479)
    at jenkins.branch.OrganizationFolder.computeChildren(OrganizationFolder.java:488)
    at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
    at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
    at jenkins.branch.OrganizationFolder$OrganizationScan.run(OrganizationFolder.java:968)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
[Thu Jul 04 12:59:03 UTC 2019] Finished organization scan. Scan took 11 sec
FATAL: Failed to recompute children of EU Keying and Linking
java.io.IOException: Communication error for url: Jenkinsfile status code: 401
    at com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.checkPathExists(BitbucketServerAPI

预期结果:没有Jenkinsfile的存储库应被忽略 实际输出:上述故障错误

詹金斯版本:2.1.83 Bitbucket分支源插件版本:2.4.5

2 个答案:

答案 0 :(得分:0)

如果存在另一个用于标记存储库有效的文件,则可以使用“远程文件插件”。

在此插件中,有一个名为Local File的字段。如果您在此处定义文件名,例如pom.xml,则只会创建具有此文件的存储库和分支。

这是来自插件的文档。

When using Remote File Plugin, you might want to build only repositories and branches which contain a certain file. In this case, you may specify a Local File in the Plugin SCM Definition. This way, Jenkins will create projects only for repositories and branches containing the file you specified.

答案 1 :(得分:0)

默认情况下,插件将尝试读取所有分支,并且没有JenkinsFile构建的分支将失败。为了克服它,对于所有测试分支(您不想构建作业),您必须维护与实际分支(要构建的分支)不同的不同分支名称。

在Job配置中,您可以使正则表达式与实际分支匹配,以便Jenkins忽略其余分支。

有关更多详细信息,请选中https://docs.cloudbees.com/docs/admin-resources/latest/plugins/bitbucket

相关问题