简体   繁体   English

Jenkins:从不同的 BitBucket 存储库触发相同的作业

[英]Jenkins: trigger the same job from different BitBucket repositories

I have 50+ repositories in a BitBucket project and I want them to execute the same job when a commit is pushed (that is maven build and deploy to artifactory).我在 BitBucket 项目中有 50 多个存储库,我希望它们在推送提交时执行相同的作业(即 maven 构建并部署到工件)。 I tried to create a Maven job and make it work, but that can be linked to only one repository.我尝试创建一个 Maven 作业并使其工作,但它只能链接到一个存储库。 I also tried installing the Bitbucket Team plugin and creating a project with it, and I think this could lead to a solution.我还尝试安装 Bitbucket Team 插件并使用它创建一个项目,我认为这可能会导致解决方案。 In fact I saw that it scans automatically all the repositories with a JenkinsFile in it, so I thought that I could create a common Pipeline on jenkins and call this pipeline from every JenkinsFile in every repository.事实上,我看到它会自动扫描所有包含 JenkinsFile 的存储库,所以我认为我可以在 jenkins 上创建一个公共管道,并从每个存储库中的每个 JenkinsFile 调用这个管道。 The problem is that I still have to create a JenkinsFile for each repository, and I don't want to do that.问题是我仍然必须为每个存储库创建一个 JenkinsFile,我不想这样做。 Is there anyway that I can trigger the same Jenkins job from all my repositories?无论如何,我可以从我的所有存储库中触发相同的 Jenkins 作业吗?

You can use Remote File Plugin for this.您可以为此使用远程文件插件。 What you need to do is,你需要做的是,

  • Create a separate repository and put your Jenkins file into it.创建一个单独的存储库并将您的 Jenkins 文件放入其中。
  • Define this repository and Jenkins file in the Remote File section of the BitBucket Team Project configuration page.在 BitBucket 团队项目配置页面的远程文件部分定义此存储库和 Jenkins 文件。

This way, for every repository in your BitBucket, this Jenkins file will be run.这样,对于 BitBucket 中的每个存储库,将运行此 Jenkins 文件。

Hope this helps.希望这可以帮助。

You can find the example screenshot below.您可以在下面找到示例屏幕截图。

在此处输入图像描述

You can find it under Project Recognizers您可以在项目识别器下找到它

在此处输入图像描述

It is under the Project Recognizers它在项目识别器下

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM