问题描述
在Jenkins中,我想将启动构建的客户端的ip传递给Jenkins作业,以便我可以在扩展"Builder"的类中或作为环境变量或任何有效方法访问该信息.
In Jenkins, I want to pass the ip of the client that initiated the build to the Jenkins job so I can access that information inside a class that extends "Builder" or as an environment variable, or anything that works.
因此,例如,在每个版本的控制台日志中,我可以打印以下内容:由user1从ip启动的作业:10.101.101.1"
So for example, in the console log of every build, I can print something like: "Job started by user1 from ip: 10.101.101.1"
我知道我可以通过使用针对Jenkins的审核试用"插件来进行审计试用,但是我想将这些信息打印到构建控制台,这样会更加直接.
I know I can get an audit trial by using the "Audit Trial" plugin for Jenkins, but I would like to print that information to the build console so it'll be more straight forward.
先谢谢了.
我想要启动作业/构建的用户/客户端的ip,这不一定是作业正在运行的jenkins从属服务器的ip.
I want the ip of the user/client that started the job/build, which is not necessarily the ip of the jenkins slave the job is running on.
推荐答案
Jenkins目前无法将客户端IP传递给变量,您在输出日志中看到的客户端IP是远程原因消息.
Jenkins not able to pass the client IP to a variable at the moment , the Client IP you saw at the output log is remote cause message.
我要说的是,在工作中获取远程IP以启用某些回调功能确实有用.或者,您可以在进行远程呼叫时将IP作为参数传递
I would say it is indeed useful to get remote IP in a job to enable some callback functions . Alternatively you can pass the IP as parameter when make the remote call
-
在jenkins job的shell脚本中回显$ ipaddr
echo $ipaddr in your shell script of jenkins job
在jenkins作业中启用字符串参数 https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build
Enable the string parameters in jenkins jobhttps://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build
拨打电话
这篇关于将客户端IP信息传递给Jenkins Job的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!