问题描述
为了使问题简单化,我知道我可以通过 https://jenkins_server/...////api/json|xml|python.我得到了很多关于该构建记录的信息.
To make the question simple, I know that I can get some build information with https://jenkins_server/...///api/json|xml|python. And I get a lot of information for that build record.
但是,我想向该构建记录添加更多信息.例如,创建的 docker 映像,或从上次构建更改为创建发行说明的票证或文件等.我该怎么做?
However, I want to add more information to that build record. For example, the docker image created, or the tickets or files changed from last build to create release note, ... etc. How do I do that?
目前,我使用脚本创建一个 json 文件作为工件并调用该 json 文件来获取这些信息,但如果我可以直接向 jenkins 构建对象添加更多数据,则似乎是重复的.
For now, I use a script to create a json file as an artifact and call that json file to get these information, but it seems a duplicate if I can add more data to the jenkins build object directly.
推荐答案
Jenkins 远程访问 API 旨在提供对通用 Jenkins-内部 信息的访问,例如内部版本号、时间戳、指纹等.
The Jenkins remote access API is designed to provide access to generic Jenkins-internal information, like build numbers, timestamps, fingerprints etc.
如果您想在那里添加自己的数据,那么您必须相应地扩展 Jenkins,例如,通过设计一个插件,将您的(自定义)信息项作为标准 Jenkins-内部"数据进行广告.如果你想这样做,你可能想看看他们处理指纹信息的方式(我发现这很有启发性).
If you want to add your own data there, then you must extend Jenkins accordingly, e.g., by designing a plugin that advertises your (custom) information items as standard Jenkins-"internal" data. If you want to do that, you may want to have a look at they way fingerprint information is handled (I found that quite instructive).
但是,我建议您坚持使用当前的方法,并将通用的 Jenkins 内部信息与特定于作业的数据分开.这样做更省力,并且可以清楚地将您自己的数据与 Jenkins 的数据分开.
However, I'd recommend that you stick with your current approach, and keep generic Jenkins-internal information separated from Job-specific data. It is less effort and clearly separates your own data from Jenkins' data.
这篇关于如何添加更多要存储在 jenkins rest api 中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!