在詹金斯,如何建立知道是谁要求他们? [英] In Jenkins, how do builds know who requested them?

查看:118
本文介绍了在詹金斯,如何建立知道是谁要求他们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要向下传递一个构建的请求者的用户名,实际上是在做工作的脚本。纵观控制台输出特定版本,第一行总是由用户foo指南,让詹金斯显然是跟踪谁引发的构建。所以它应该有可能向下传递信息给作业.....现在的问题是,怎么了?

I need to pass the username of the requestor of a build down to the script that is actually doing the work. Looking at the console output for a particular build, the first line is always "Started by user foo," so Jenkins is clearly keeping track of who triggered the build. So it should be possible to pass that information down to the job..... The question is, how?

推荐答案

用户名不放在一个易于获取环境变量,但可以使用的 XML(或JSON或Python)API - 只要你开始构建,的http:// [詹金斯服务器] /工作/ [作业名称] / [集结号] / API / XML 填充了细节:

The username isn't put in an easy-to-fetch environment variable, but you can get it using the xml (or json or python) api - as soon as you start a build, http://[jenkins-server]/job/[job-name]/[build-number]/api/xml is populated with details:

<freeStyleBuild>
    <action>
        <cause>
            <shortDescription>Started by user foobar</shortDescription>
            <userName>foobar</userName>
        </cause>
    </action>
    <building>true</building>
    [...]

这篇关于在詹金斯,如何建立知道是谁要求他们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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