【问题标题】:Bitbucket branch source plugin fails to scan if jenkinsfile doesnt exist如果 jenkinsfile 不存在,Bitbucket 分支源插件无法扫描
【发布时间】:2019-11-15 05:51:39
【问题描述】:

我设置了 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 的存储库 实际输出:上面提到的失败错误

Jenkins 版本:2.1.83 Bitbucket 分支源码插件版本:2.4.5

【问题讨论】:

    标签: jenkins plugins bitbucket cloudbees bitbucket-pipelines


    【解决方案1】:

    如果有另一个文件用于标记存储库对构建有效,您可以使用远程文件插件。

    在这个插件中有一个名为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.

    【讨论】:

      【解决方案2】:

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

      并且在 Job 配置中,你可以让正则表达式匹配你的实际分支,这样 Jenkins 就会忽略剩余的分支。

      更多详情请查看https://docs.cloudbees.com/docs/admin-resources/latest/plugins/bitbucket

      【讨论】:

        猜你喜欢
        • 2016-10-19
        • 1970-01-01
        • 2014-12-23
        • 1970-01-01
        • 1970-01-01
        • 2016-12-12
        • 1970-01-01
        • 1970-01-01
        • 2019-01-21
        相关资源
        最近更新 更多