gpt4 book ai didi

git - Jenkins + Git Publisher - 如何推回 {GIT_BRANCH}?

转载 作者:太空狗 更新时间:2023-10-29 12:48:08 29 4
gpt4 key购买 nike

我在 Jenkins 1.500 上使用当前版本的 Git 插件(SCM 提供者和发布者)。 SCM 轮询工作正常,使用我的 git HTTP URL 和“feature-*”的“branches to build”设置。这会选择对任何分支的更改,例如“feature-1234”,运行构建/测试/覆盖任务,并报告成功或失败。所有这一切都工作正常,包括来自集成分支的 merge ,代码应该在成功构建和代码审查后结束。

问题在于试图将已完成的构建分支推回原点,在同一个“feature-1234”分支上。在这种情况下,构建变量“GIT_BRANCH”包含“origin/feature-1234”,在成功构建后,它会在 Git Publisher 中产生以下错误和失败:

Pushing HEAD to branch origin/feature-1234 at repo origin
ERROR: Failed to push branch origin/feature-1234 to origin
hudson.plugins.git.GitException: Command "/usr/bin/git push https://jenkins:jenkinsPWD@myproject.com/git/project HEAD:origin/feature-1234" returned status code 1:
stdout:
stderr: error: unable to push to unqualified destination: origin/feature-1234
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to 'https://jenkins:jenkinsPWD@myproject.com/git/project'

at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:897)
at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:858)
at hudson.plugins.git.GitAPI.push(GitAPI.java:915)
at hudson.plugins.git.GitPublisher$4.invoke(GitPublisher.java:351)
at hudson.plugins.git.GitPublisher$4.invoke(GitPublisher.java:333)
at hudson.FilePath.act(FilePath.java:865)
at hudson.FilePath.act(FilePath.java:838)
at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:333)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:810)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:785)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:732)
at hudson.model.Run.execute(Run.java:1582)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)
Build step 'Git Publisher' changed build result to FAILURE
Build step 'Git Publisher' marked build as failure

看到里面多出来的“起源”了吗? origin/feature-1234 <== 这是 ${GIT_BRANCH} 的当前值,虽然我知道它是一个远程分支,但它阻止我运行我们想要遵循的流程。

如果我遗漏了一些简单的东西,我很乐意听到。但是我已经为我构建的各种 git 相关部分尝试了许多不同的设置,似乎没有任何东西允许我将 merge 和测试的代码提交回工作分支(而不是集成分支,这很容易做到。

最佳答案

我的解决方法似乎是手动推送分支,至少在每次都相同的时候。

关于git - Jenkins + Git Publisher - 如何推回 {GIT_BRANCH}?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14766214/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com