BitBucket不会更新PR的refspec,从而导致Jenkins建立旧的提交 [英] BitBucket does not update refspec for PR, causing Jenkins to build old commits

查看:110
本文介绍了BitBucket不会更新PR的refspec,从而导致Jenkins建立旧的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将本地BitBucket服务器与Git一起使用.我正在尝试开始进行Continous Integration,因此我设置了本地Jenkins实例.目标是让Jenkins签出拉取请求并构建项目,然后将结果报告给BitBucket.

I am using a local BitBucket server with Git. I am trying to get started with Continous Integration so I've set up a local Jenkins instance. The goal is to have Jenkins check out pull-requests and build the project, and then report back to BitBucket with the result.

在BitBucket中,我正在使用将Webhook链接到Jenkins for Stash 会在每次创建/更新请求请求时通知我的Jenkins实例.

In BitBucket I am using Webhook to Jenkins for Stash which notifies my Jenkins instance each time a pull-request is created/updated.

在Jenkins中,我正在使用隐藏请求构建器插件从上面的插件收到通知后,让Jenkins检出pullrequest.我已经使用了文档中的设置,即

In Jenkins i am using Stash pullrequest builder plugin to have Jenkins checkout the pullrequest, when notified from the plugin above. I have used the settings in the documentation, i.e.

Refspec: +refs/pull-requests/*:refs/remotes/origin/pr/*
Branch Specifier: origin/pr/${pullRequestId}/from

这几乎可行...

当我在BitBucket中创建新的拉取请求时,Jenkins被打扰,检出PR并将结果报告回BitBucket.到目前为止,一切都很好.

When i create a new pull request in BitBucket, Jenkins get nofitied, checks out the PR and report the result back to BitBucket. So far so good.

但是,当我更新PR(即提交新代码并推送到BitBucket)时,Jenkins会被触发,但仍会签出PR中的先前提交,而不是新提交.

However when I update the PR (i.e. commit new code and push to BitBucket), Jenkins gets triggered but still checks out the previous commit in the PR, and not the new commit.

我进行了一些调查,但被卡住了.据我了解,Refspec指定我应该在本地将refs/remotes/origin/pr/*映射到refs/pull-requests/*.但是,当我对现有PR进行新提交时,BitBucket似乎不更新PR的引用,这导致Jenkins仅找到旧的PR.

I've done some investegation but got stuck. From what I understand Refspec specifies that i should map refs/remotes/origin/pr/* to refs/pull-requests/* locally. However it does not seem like BitBucket updates the refs for the PR when i do a new commit to an existing PR, which causes Jenkins only to find the old one.

在提交并将更新推送到现有PR之后运行git ls-remote origin时,我得到了:

When I run git ls-remote origin after commiting and pushing an update to an existing PR i get this:

edf245 (new commit)...             refs/heads/feature/Name-Of-My-Branch-That-I-Created-Pull-Request-From-pr
af774f (previous commit in PR)...  refs/pull-requests/69/from
7fa82b (master)...                 refs/pull-requests/69/merge

但是,在访问BitBucket中的PR页面之后,引用似乎已更新,并且我得到了以下结果:

However after visiting the PR-page in BitBucket, the refs seems to be updated and i get the following result:

edf245 (new commit)...             refs/heads/feature/Name-Of-My-Branch-That-I-Created-Pull-Request-From-pr
edf245 (new commit)...             refs/pull-requests/69/from
7fa82b (master)...                 refs/pull-requests/69/merge

如果我在此之后手动触发Jenkins,它将建立最新的提交.

And if i manually trigger Jenkins after this it build the latest commit.

所以我的问题是,直到我访问BitBucket中的实际PR页之前,BitBucket似乎都无法使refspec更加完美.我该如何解决?

So my problem is that BitBucket does not seem to upfate the refspec until I visit the acutal PR-page in BitBucket. How can i fix this?

Google搜索了我最终遇到的问题

Googling the problem I ended up here where it seems like the behaviour is by design...

推荐答案

有关为什么会出现问题"以及为什么以这种方式设计Bitbucket的解释,请参阅Daves的答案.

See Daves answer for an explanation on why this "problem" arise and why Bitbucket is designed in this way.

但是我能够通过更改Jenkin插件中的设置来解决我的特定问题,以欺骗" Bitbucket来更新引用.

However i was able to solve my specific problem by changing the settings in the Jenkin-plugin, to "trick" Bitbucket into updating the refs.

通过在Jenkins中将选项Build only if Stash reports no conflicts设置为true(在工作中为Build Trigger),您可以强制Bitbucket更新引用,这意味着您将签出正确的提交

By setting the option Build only if Stash reports no conflicts to true in Jenkins (Under Build Trigger for the job), you force Bitbucket to update the refs which means you will check out the correct commit

请参见 https://github.com/nemccarthy/stash- pullrequest-builder-plugin/issues/75 了解详情

这篇关于BitBucket不会更新PR的refspec,从而导致Jenkins建立旧的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆