[英]How can I make a Jenkins build for a GitHub repository be triggered by a push to a different repository?
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). 我有一个Python代码包的GitHub存储库(称为X),还有一个单独的GitHub存储库(称为X-tests),其中包含该程序包的测试(它们是独立的存储库,因为包含测试的容器是私有的,因此它可以运行其他私人代码)。 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 (eg making a pip wheel). 我想这样做,以便当有人推送到X存储库时,Jenkins将从X-tests存储库运行测试,然后执行与X存储库相关的其他操作(例如,制作一个pip wheel)。
The only way I can think of to do this is to have three separate Jenkins jobs: 我能想到的唯一方法是拥有三个单独的詹金斯工作:
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. 作业1是name -commit-stage,作业2是name -test-stage或name-integration-stage,第三项是您的摆轮。
You can see a more complex pipeline in the build pipeline jenkins plugin. 您可以在构建管道jenkins插件中看到更复杂的管道。
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. 检查您的第三个作业是否应该使用作业1的工件而不是存储库X。这将给您的管道带来原子性,因为有人可以在作业开始时将某些东西推入存储库X。 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). “ 复制工件插件”对此很有用,或者您可以仅引用本地作业1工作区作为作业3的源(作为构建步骤中的参数)。
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. 您还需要确保在更改存储库X之前先推送对存储库X测试的更改,因为作业2可能会使用存储库X测试中与存储库X不同步的代码,从而导致测试失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.