如何远程触发Jenkins多分支管道项目构建? [英] How to remotely trigger Jenkins multibranch pipeline project build?

查看:28
本文介绍了如何远程触发Jenkins多分支管道项目构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题主要是这样说的.如何从远程 git 存储库触发 Jenkins 多分支管道项目构建?

Title mostly says it. How can you trigger a Jenkins multibranch pipeline project build from a remote git repository?

远程触发构建"构建触发选项似乎不起作用,因为没有保存您设置的令牌.

The "Trigger builds remotely" build trigger option does not seem to work, since no tokens that you set are saved.

推荐答案

目前(Jenkins 2.22)Trigger builds remote"构建触发器选项在多分支管道作业配置中可见,但不起作用(如果您选中它并指定一个令牌,无论如何保存后它会被重置).根据this,无法设置触发器是故意的,而是一个错误它完全是一个选项.

At the moment (Jenkins 2.22) the "Trigger builds remotely" build trigger option is visible in the multibranch pipeline job configuration, but does not work (if you check it and specify a token, it gets reset after saving anyway). According to this, it is intentional that the trigger cannot be set, but a bug that it appears as an option at all.

在同一线程中,他们解释了如何为多分支管道项目中的每个单独项目(分支)触发构建.我需要的是一个动态设置,它适用于在设置触发器后创建的分支,而不是来自线程的建议端点(/job/project-name/job-name/build,应该是 /job/job-name/project-name/build ,因为项目是从作业中的分支创建的),我发现要使用的端点是 /job/job-名称/构建.为了使其工作,您必须使用 API 令牌创建一个用户(转到管理 Jenkins -> 管理用户 -> 齿轮图标 -> 显示 API 令牌),并在您的请求中使用这些作为用户名和密码.

In the same thread they explain how to trigger builds for each individual project (branch) in a multibranch pipeline project. What I needed was a dynamic setup that would work for branches created after setting up the trigger, so rather than the suggested endpoint from the thread (/job/project-name/job-name/build, which should have been /job/job-name/project-name/build , since projects are created from branches in a job), I found that the endpoint to use is /job/job-name/build. In order for that to work you have to create a user with an API token (go to Manage Jenkins -> Manage Users -> Gear icon -> Show API Token), and use those as username and password in your request.

对于那些习惯于使用 Jenkins REST API 的人来说,解决方案可能是显而易见的,但是当您对多分支管道项目和 REST API 都不熟悉时,明确表示并没有什么坏处.

The solution might be obvious for those used to working with Jenkins REST API, but when you are new to both multibranch pipeline projects and the REST API, it doesn't hurt to be explicit.

这篇关于如何远程触发Jenkins多分支管道项目构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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