繁体   English   中英

“java.lang.Exception: None or multiple repos”与 Jenkins 多分支管道中的 BitBucket Notifier

[英]"java.lang.Exception: None or multiple repos" with BitBucket Notifier in Jenkins multi-branch pipeline

我在 Jenkins 上有一个多分支声明性管道,它由来自我的 Bitbucket 云帐户的回购事件触发,我希望它向 Bitbucket 报告结果。

我的 Jenkinsfile 如下所示:

pipeline {
    agent any
    stages {
        stage('Prepare Env') {
            steps {
                bitbucketStatusNotify(buildState: 'INPROGRESS')
                sh "npm i"
            }
            post {
                success {
                    bitbucketStatusNotify(buildState: 'SUCCESSFUL')
                }
                failure {
                    bitbucketStatusNotify(buildState: 'FAILED')
                }
            }
        }
    }
}

我发现,当 Jenkins 构建失败时,当 Jenkins 构建失败时,第二次和所有连续提交到拉取请求会导致一个条件,当使用消息通知 Bitbucket 构建结果时: java.lang.Exception: None or multiple repos

这在某种程度上与日志中的第一行之一一致: Fetching changes from 2 remote Git repositories

然而,我实际上只有一个存储库,不知道为什么 Jenkins 将其识别为多个。

如何让我的构建停止看到多个回购并成功?

完整日志如下:

Branch event
Checking out git https://bitbucket.org/mycompany/myproject.git https://bitbucket.org/mycompany/myproject.git into /var/lib/jenkins/workspace/myproject_PR-48-TV7ILAHCKATC6ZK26DHNTXI6KKLEGO3RSNDKAL2363W5GU5TABFQ@script to read Jenkinsfile
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from 2 remote Git repositories
 > /usr/bin/git config remote.origin.url https://bitbucket.org/mycompany/myproject.git # timeout=10
Fetching without tags
Fetching upstream changes from https://bitbucket.org/mycompany/myproject.git
 > /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials Migrated by JIRA Plugin
 > /usr/bin/git fetch --no-tags --progress https://bitbucket.org/mycompany/myproject.git +refs/heads/VE-3869-dodawanie-edycja-i-usuwanie-aktu:refs/remotes/origin/PR-48
 > /usr/bin/git config remote.upstream.url https://bitbucket.org/mycompany/myproject.git # timeout=10
Fetching without tags
Fetching upstream changes from https://bitbucket.org/mycompany/myproject.git
using GIT_ASKPASS to set credentials Migrated by JIRA Plugin
 > /usr/bin/git fetch --no-tags --progress https://bitbucket.org/mycompany/myproject.git +refs/heads/master:refs/remotes/upstream/master
Merging remotes/upstream/master commit 98a73e74fed491c44dcb1b361a1eedb737e8960c into PR head commit bd199dfbe53f7a9cb0b71b45e048b98f4f173835
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f bd199dfbe53f7a9cb0b71b45e048b98f4f173835
 > /usr/bin/git merge 98a73e74fed491c44dcb1b361a1eedb737e8960c # timeout=10
 > /usr/bin/git rev-parse HEAD^{commit} # timeout=10
Merge succeeded, producing e402581b4779a8ce8e4d0b3af0a543ae99c1dbd4
Checking out Revision e402581b4779a8ce8e4d0b3af0a543ae99c1dbd4 (PR-48)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f e402581b4779a8ce8e4d0b3af0a543ae99c1dbd4
Commit message: "Merge commit '98a73e74fed491c44dcb1b361a1eedb737e8960c' into HEAD"
 > /usr/bin/git rev-list --no-walk 760dbaed862dfc7416eb5d2e158499cb6ad941cb # timeout=10
[Bitbucket] Notifying pull request build result
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/myproject_PR-48-TV7ILAHCKATC6ZK26DHNTXI6KKLEGO3RSNDKAL2363W5GU5TABFQ
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from 2 remote Git repositories
 > /usr/bin/git config remote.origin.url https://bitbucket.org/mycompany/myproject.git # timeout=10
Fetching without tags
Fetching upstream changes from https://bitbucket.org/mycompany/myproject.git
 > /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials Migrated by JIRA Plugin
 > /usr/bin/git fetch --no-tags --progress https://bitbucket.org/mycompany/myproject.git +refs/heads/VE-3869-dodawanie-edycja-i-usuwanie-aktu:refs/remotes/origin/PR-48
 > /usr/bin/git config remote.upstream.url https://bitbucket.org/mycompany/myproject.git # timeout=10
Fetching without tags
Fetching upstream changes from https://bitbucket.org/mycompany/myproject.git
using GIT_ASKPASS to set credentials Migrated by JIRA Plugin
 > /usr/bin/git fetch --no-tags --progress https://bitbucket.org/mycompany/myproject.git +refs/heads/master:refs/remotes/upstream/master
Merging remotes/upstream/master commit 98a73e74fed491c44dcb1b361a1eedb737e8960c into PR head commit bd199dfbe53f7a9cb0b71b45e048b98f4f173835
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f bd199dfbe53f7a9cb0b71b45e048b98f4f173835
 > /usr/bin/git merge 98a73e74fed491c44dcb1b361a1eedb737e8960c # timeout=10
 > /usr/bin/git rev-parse HEAD^{commit} # timeout=10
Merge succeeded, producing e74140b80595d0bf0ee1da066a6b34dab9797f2a
Checking out Revision e74140b80595d0bf0ee1da066a6b34dab9797f2a (PR-48)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f e74140b80595d0bf0ee1da066a6b34dab9797f2a
Commit message: "Merge commit '98a73e74fed491c44dcb1b361a1eedb737e8960c' into HEAD"
 > /usr/bin/git rev-list --no-walk 760dbaed862dfc7416eb5d2e158499cb6ad941cb # timeout=10
First time build. Skipping changelog.
[Bitbucket] Notifying pull request build result
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Prepare Env)
[Pipeline] bitbucketStatusNotify
Post stage
[Pipeline] bitbucketStatusNotify
Error when executing failure post condition:
java.lang.Exception: None or multiple repos
    at org.jenkinsci.plugins.bitbucket.scm.GitScmAdapter.getCommitRepoMap(GitScmAdapter.java:53)
    at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper.createBuildStatusResources(BitbucketBuildStatusHelper.java:87)
    at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper.createBuildStatusResources(BitbucketBuildStatusHelper.java:140)
    at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusHelper.notifyBuildStatus(BitbucketBuildStatusHelper.java:231)
    at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:206)
    at org.jenkinsci.plugins.bitbucket.BitbucketBuildStatusNotifierStep$Execution.run(BitbucketBuildStatusNotifierStep.java:152)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
    at hudson.security.ACL.impersonate(ACL.java:290)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
Stage "Build" skipped due to earlier failure(s)

简短回答:删除所有bitbucketStatusNotify调用。 通知是隐含的,因为它是一个 bitbucket 工作。

长答案:在同样的错误上花了 3 个小时后,我们看到问题与“bitbucketStatusNotify”插件有关。

您指出的错误“从 2 个远程 Git 存储库获取更改”似乎与 jenkins 管理 PR 作业的方式有关,它使bitbucketStatusNotify插件失败。

由于它是一个 bitbucket 插件工作,bitbucket 的通知是自动完成的,所以如果你删除 bitbucketStatusNotify 调用,它应该按预期工作

这已由此 PR 修复,但截至 1.4.1 尚未标记发布

https://github.com/jenkinsci/bitbucket-build-status-notifier-plugin/pull/43

暂无
暂无

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

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