【问题标题】:Jenkins Pipeline having "Multiple candidate revisions" and is picking old oneJenkins Pipeline 具有“多个候选版本”并且正在选择旧版本
【发布时间】:2018-09-26 14:55:15
【问题描述】:

我配置了一个 Jenkins 多分支管道,它应该从远程 GIT 存储库获取源以进行构建。 Jenkins no 似乎“随机”为构建选择一个旧提交,并在构建日志文件中显示消息“多个候选修订”。

我的管道看起来像:

checkout(
        [
            $class: 'GitSCM', 
            branches: [[name: "release/0.0.1"]],
            doGenerateSubmoduleConfigurations: false, 
            extensions: [
                [$class: 'MessageExclusion', excludedMessage: '(?s)^\\[DOC\\] Robot.*']
            ], 
            submoduleCfg: [], 
            userRemoteConfigs: [[credentialsId: 'xxx', url: "https://somerepo.net/scm/someproject/somecomponent.git"]]
        ]
    )

来自 Jenkins 的日志文件显示:

[Pipeline] checkout
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://somerepo.net/scm/someproject/somecomponent.git # timeout=10
Fetching upstream changes from https://somerepo.net/scm/someproject/somecomponent.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://somerepo.net/scm/someproject/somecomponent.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse release/0.0.1^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/release/0.0.1^{commit} # timeout=10
Multiple candidate revisions
Checking out Revision 301c954e576bd3f03ef787563f159d541cb6e8d2 (release/0.0.1)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 301c954e576bd3f03ef787563f159d541cb6e8d2
Commit message: "Some old commit message"
 > git rev-list --no-walk 88be7349bd7b6ddb0654325e6b07cf1da2f8a35b # timeout=10

在日志文件中,我可以看到 Jenkins 正在使用来自 release/0.0.1 的旧版本 301c954e576bd3f03ef787563f159d541cb6e8d2 而不是来自 refs/remotes/origin/release./0.0 的新远程 88be7349bd7b6ddb0654325e6b07cf1da2f8a35b。

任何想法这里出了什么问题?

【问题讨论】:

    标签: git jenkins continuous-integration jenkins-plugins continuous-deployment


    【解决方案1】:

    我不是 git 大师,但请尝试指定

    分支:[[名称:“*/release/0.0.1”]],

    而不是

    分支:[[名称:“release/0.0.1”]],

    【讨论】:

    • 有了这种适应,它至少可以工作,但在我看来是一种解决方法。不,我可以看到 Jenkins 正在检查:> git rev-parse refs/remotes/origin/release/0.0.1^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/release/0.0。 1^{commit} # timeout=10 对 refs/remotes/origin/origin/release/0.0.1 的检查会报错。
    【解决方案2】:

    我认为这可能与使用 git checkout 的 LocalBranch 选项有关。如果您以前在工作区中使用过它:

    extensions: [
        [$class: 'LocalBranch', localBranch: "release/0.0.1"]
    ]
    

    Jenkins Git 插件将在本地签出该分支(而不是仅使用当时引用的修订版)。之后,它将有一个本地分支,它可以在检查是否有来自上游的新更改之前匹配该分支。听起来指导方针是使用或不使用LocalBranch,但在它们之间进行更改可能会导致问题。

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题,并通过清理工作区目录来“解决”它,比如here。下一次运行时问题就消失了。

      旁注:“多个候选修订”可能this issue有关。

      【讨论】:

        猜你喜欢
        • 2017-07-04
        • 2018-04-16
        • 2016-09-04
        • 2018-08-10
        • 1970-01-01
        • 2018-04-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多