If you want to access it via shell script, you can install the EnvInject 
plugin and configure the plugin to Evaluated Groovy script

import hudson.model.*
import static hudson.model.Cause.RemoteCause


def ipaddress=""
for (CauseAction action : currentBuild.getActions(CauseAction.class)) {
    for (Cause cause : action.getCauses()) {
        if(cause instanceof RemoteCause){
             ipaddress=cause.addr
             break;
        }
    }
}
return ["ip":ipaddress]

then access the variable $ip in shell script

On Wednesday, November 23, 2016 at 11:58:55 AM UTC+8, Ted Xiao wrote:
>
> javadoc for RemoteCause.getAddr()
> http://javadoc.jenkins.io/hudson/model/Cause.RemoteCause.html#getAddr()
>
>
> On Wednesday, November 23, 2016 at 11:56:27 AM UTC+8, Ted Xiao wrote:
>>
>> You call access it by RemoteCause, pseudo code:
>>
>>
>> for (CauseAction action : build.getActions(CauseAction.class)) {
>>     for (Cause cause : action.getCauses()) {
>>         if(cause instanceof RemoteCause){
>>         //blah
>>         }
>>     }
>> }
>>
>>
>>
>>
>> On Tuesday, November 22, 2016 at 8:16:45 PM UTC+8, Andreas Wuz wrote:
>>>
>>> Hi @ all,
>>>
>>> I am implementing an infrastructure with Jenkins. I hava a parameterized 
>>> job with a basic shell script. This script can be run remotely, i.e. it 
>>> could be triggered over an http-request like 
>>> http://testserver.de:8009/job/receiveCSR/build?token=123. Now I need 
>>> the IP of the client, which set triggered this build. When I see the 
>>> console output 
>>>
>>> Started by remote host 10.1.1.111
>>>
>>> I think, this should be possible, isn't it? If not, is there any plugin 
>>> which I can use for this?
>>>
>>> Thanks for your help!
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/17425bbd-4b6b-4833-869d-10370a6f838f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to