3

我正在使用 Jenkins Perforce 插件,并轮询工作区的更改,然后在捕获的更改列表上运行构建。

问题:如果在同一个轮询中捕获了多个更改列表,则构建仅在最后一个更改列表上运行(而不是在所有更改列表上)

P4_CHANGELIST 包含最后一个更改列表。

如何在每个捕获的更改列表上运行构建?

4

4 回答 4

2

更正确的实现方法是将您的作业参数化以在特定变更集上运行,然后在您的 perforce 服务器中编写一个提交后触发器,以远程启动 Jenkins 作业,无论是使用 CLI 还是通过像 curl 这样简单的东西。这具有在提交时构建每个变更集的额外优势,而不是在轮询间隔发生时分批构建。

如前所述,Jenkins 核心中尚不存在此功能。幸运的是,有一张票可以直接将此功能添加到 Perforce 插件中。这实质上会导致它只在运行时构建下一个更改,并且应该相当容易实现,但缺点是每个轮询周期只运行一个构建。

https://issues.jenkins-ci.org/browse/JENKINS-17889

于 2013-05-09T02:33:58.347 回答
2

至于为每个更改列表运行构建,这是一个尚未执行的功能请求(首先在This Question中回答)。

具体的变更列表信息在作业的元数据中。我不确定您是否可以在构建阶段使用它,但之后您肯定可以看到它。该Summary of Changes部分仅显示自上次构建以来的更改列表。

builds每个作业的目录中,有一个changelog.xml文件包含每个单独的“更改日志条目”的条目,在 Perforce 的情况下是一个更改列表。每个changenumber元素entry表示来自 perforce 的更改列表编号。

最后,如果您想为 Jenkins 服务器外部的自动化流程抓取信息,您可以通过以下方式检索上次构建的 XML 数据:

http://{sereveraddress}/job/{jobname}/lastSuccessfulBuild/api/xml

这将返回一个 XML 结构,其中包含 s 的changeSet列表,item其中每个都有 s changeNumber(以及 themsg和 each affectedPath)。此数据也以 json 格式提供。

于 2013-05-08T14:00:42.257 回答
0

Solution was found!

The problem was with the polling that didn't provided the multiple changelists info. Instead of polling the branch with Jenkins\Perforce plugin, I used a Perforce query to find all queries that were submitted since last build.

Here is what I did in order to solve the problem:

  1. I've created a standalone job to build a changelist by it's a number.
  2. I've created a job the finds all changelists that were submitted since the last changelist build (param LATEST_CHANGELIST_NUMBER that is saved in a file or registry). In order to do that I used the Perforce query: p4 changes "//projects/BRANCH_NAME/...@>LATEST_CHANGELIST_NUMBER"

Then I build each of the found changelists and update the LATEST_CHANGELIST_NUMBER (in a file for example).

It works fine! Thanks for the ideas!

于 2013-06-16T08:22:11.220 回答
0

每次更改轮询

检查构建将在每个构建发生 1 次更改时发生,未选中您将获得自静默期开始以来的所有更改。

于 2020-07-04T21:11:20.017 回答