如何通过推送到不同的存储库来触发GitHub存储库的Jenkins构建? [英] How can I make a Jenkins build for a GitHub repository be triggered by a push to a different repository?

查看:149
本文介绍了如何通过推送到不同的存储库来触发GitHub存储库的Jenkins构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Python代码包和一个单独的GitHub存储库(称为X-tests)有一个GitHub存储库(称为X),它包含该包的测试(它们是独立的存储库,因为包含测试的存储库是私人的,因此它可以运行其他私人代码)。我想这样做是为了当有人推送到X仓库时,Jenkins将运行X测试仓库中的测试,然后做一些与X仓库相关的其他内容(例如制作一个点子轮)。



我能想到的唯一方法就是做三个独立的Jenkins作业:


  1. 一个无所事事的工作,其GitHub仓库是X,其中构建是通过推送到X来触发的。

  2. 一个运行测试的作业,其GitHub存储库是X-test,其中构建是通过完成作业1

  3. 来触发的,这个作业可以让制作轮等的作业,其GitHub存储库为X,其中构建由作业2完成触发

有没有更简单的方法可以做到这一点? 我认为这是实现一个简单的 build-test-posttest 管道的非常标准的方法。作业1是 name -commit-stage,作业2是 name - 测试阶段或名称集成阶段以及第三个作业。

>

您可以在复制神器插件对此很有用,或者您可以引用本地作业1工作区作为工作源3(作为构建步骤中的参数)。



您还需要确保对存储库X-测试应在更改存储库X之前推送,因为作业2可能使用与存储库X不同步的存储库X-Test中的代码,导致测试失败。


I have a GitHub repository (call it X) for a Python code package, and a separate GitHub repository (call it X-tests) that contains the tests for that package (they're separate repositories because the one containing the tests is private so that it can run other private code). I would like to make it so that when someone pushes to the X repository, Jenkins will run the tests from the X-tests repository, and then do some other stuff related to the X repository (e.g. making a pip wheel).

The only way I can think of to do this is to have three separate Jenkins jobs:

  1. a job that does nothing, whose GitHub repository is X, where builds are triggered by pushes to X
  2. a job that runs the tests, whose GitHub repository is X-test, where builds are triggered by completion of job 1
  3. a job that makes the pip wheel etc., whose GitHub repository is X, where builds are triggered by completion of job 2

Is there any simpler way to do it?

解决方案

I think this is a pretty standard approach to implementing a simple build-test-posttest pipeline. Job 1 is name-commit-stage, job 2 is name-test-stage or name-integration-stage and a third job for your pip-wheel.

You can see a more complex pipeline in the build pipeline jenkins plugin.

Check if your third job should be using job 1's artifacts instead of repository X. This will bring atomicity to your pipeline as someone could push something to your repository X while a job has already started. The Copy Artifact Plugin is useful for that, or you can just reference the local job 1 workspace as a source of your job 3 (as a parameter in a build step).

You also need to make sure that changes to repository X-Tests should be pushed before changes to repository X, as job 2 may use code in repository X-Tests that is not in sync with repository X, leading to test failures.

这篇关于如何通过推送到不同的存储库来触发GitHub存储库的Jenkins构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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