Re: Getting the remote IP of the client which triggered a build

2016-11-23 Thread Andreas Wuz
Thanks, it works fine!

Am Mittwoch, 23. November 2016 08:13:35 UTC+1 schrieb Ted Xiao:
>
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/fa804fae-f6ce-4e0b-afa5-7d72a79d2031%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the remote IP of the client which triggered a build

2016-11-22 Thread Ted Xiao
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 jenkinsci-users+unsubscr...@googlegroups.com.
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.


Re: Getting the remote IP of the client which triggered a build

2016-11-22 Thread Ted Xiao
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/58ff9dd9-cca7-4e79-87a6-084e8ffba379%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the remote IP of the client which triggered a build

2016-11-22 Thread Ted Xiao
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/dfecde97-5533-4692-b3ca-03e341e58ee6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Getting the remote IP of the client which triggered a build

2016-11-22 Thread Andreas Wuz
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/82214c37-777a-4918-8968-23b42acc5f7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.