如何使用 Jenkins CI 构建推送到 github 的新分支?

发布于 2024-12-14 01:55:23 字数 432 浏览 3 评论 0原文

我已经为 Rails3 应用程序设置了 Jenkins 来构建规范。 通过 google 可以找到很多关于如何在 github 推送上设置构建触发器的帖子。

但我想要的是构建推送到 Github 的新远程分支。 例如,

我有一个存储库 origin/master。我克隆了存储库,创建了一个新分支,进行了一些提交并将该分支推送到原点 git push -u origin new_branch

现在我希望 Jenkins 在原点上构建这个新推送的分支。

如果构建成功,Jenkins 应该自动将其合并到 origin/master 中。

Jenkins插件有github、git插件。但需要填写分支名称。相反,我想动态构建 new_branch 。

我该如何设置这样的过程?

I've setup the Jenkins for the rails3 app to build the specs.
One can find many posts via google on how to setup the build trigger on the github push.

But what I want is to build the new remote branch pushed to Github.
e.g.

I've a repo origin/master. I cloned the repo, created a new branch, did some commits and pushed that branch to origin git push -u origin new_branch

Now I want the Jenkins to build this newly pushed branch on the origin.

If the build is successful, then Jenkins should merge it into origin/master automatically.

The Jenkins plugin has github, git plugin. But it requires to put the branch name. Instead I want to build the new_branch dynamically.

How can I setup such process?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

未蓝澄海的烟 2024-12-21 01:55:23

如果我没记错的话,分支名称不是必填项。你需要测试它,但我认为如果你不填写它,Jenkins 会测试存储库中的所有新提交,无论哪个分支受到影响。

但我建议你不要自动合并。你不想那样,相信我。 :-)

If I remember correctly branch name is not a required entry. You need to test it, but I think if you do not fill it, Jenkins tests all new commit in the repo regardless which branch is affected.

But I recommend you do not merge automatically. You do not want that, trust me. :-)

[旋木] 2024-12-21 01:55:23

仅使用 github 和 gitgub 参数插件似乎无法做到这一点。如果您在要构建的分支中指定branch_regex***,Jenkins 总是在它看到的一堆分支中构建最新的提交。必须指定一个分支,以便 Jenkins 在该分支中的最新提交上进行构建。我还看到一些 多分支管道 的答案,但不确定如何以这种方式部署。根本没有具体的指示。

It seems can not do that with only github and gitgub parameter plugin. If you specify branch_regex*** in Branch to build, Jenkins always build the latest commit in the bunch of branches that it saw. Must specify a branch in order Jenkins to build on the latest commit in that branch. I also see some answer with Multi Branch Pipeline but not sure how to deploy that way. There is no specific instruction at all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文