Need Help in executing Rest API in Jenkins Job

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Need Help in executing Rest API in Jenkins Job

phanindra m
Hi,

I'm Trying to Run Rest API in Jenkins Job, but facing few issues. 

below command will fetch the session id of an application and stores it in a var variable. this command is working fine in GIT Bash, but when i trying to run this command in Execute Shell option in jenkins it is not working.  So can any one help me on this.

var=$(curl --silent 'http://URL/Login?sUserId=UserID&sPassword=password' | sed -nr 's/.*>(.*)<.*/\1/p')
echo $var

Thanks In Advance,

Phani

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a1358aa9-d81f-44e4-a75c-b6fdf479c3f0%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Need Help in executing Rest API in Jenkins Job

Björn Pedersen
Hi,

from your GIT Bash mention I assume that you are  running on Windows.
Are you sure jenkins is using your git bash as shell, and not either another bash or powershell?

Or is it even running on a different host, where  may some programms (curl/sed) are not available?
Try running just curl to see the output before trying to catch the result.


Björn
Am Dienstag, 14. Januar 2020 05:43:38 UTC+1 schrieb phanindra m:
Hi,

I'm Trying to Run Rest API in Jenkins Job, but facing few issues. 

below command will fetch the session id of an application and stores it in a var variable. this command is working fine in GIT Bash, but when i trying to run this command in Execute Shell option in jenkins it is not working.  So can any one help me on this.

var=$(curl --silent '<a href="http://URL/Login?sUserId=UserID&amp;sPassword=password" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FURL%2FLogin%3FsUserId%3DUserID%26sPassword%3Dpassword\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGtbnQlyPVIwhB-iHPZUV0e-LHcaw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FURL%2FLogin%3FsUserId%3DUserID%26sPassword%3Dpassword\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGtbnQlyPVIwhB-iHPZUV0e-LHcaw&#39;;return true;">http://URL/Login?sUserId=UserID&sPassword=password' | sed -nr 's/.*>(.*)<.*/\1/p')
echo $var

Thanks In Advance,

Phani

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ae7358ee-7325-498e-829a-71d15597b1dc%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Need Help in executing Rest API in Jenkins Job

ramesh pasham
In reply to this post by phanindra m
Hi Phani,
Could you please provide the error log if you can?

thanks,
Ramesh

On Tue, Jan 14, 2020 at 10:13 AM phanindra m <[hidden email]> wrote:
Hi,

I'm Trying to Run Rest API in Jenkins Job, but facing few issues. 

below command will fetch the session id of an application and stores it in a var variable. this command is working fine in GIT Bash, but when i trying to run this command in Execute Shell option in jenkins it is not working.  So can any one help me on this.

var=$(curl --silent 'http://URL/Login?sUserId=UserID&sPassword=password' | sed -nr 's/.*>(.*)<.*/\1/p')
echo $var

Thanks In Advance,

Phani

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a1358aa9-d81f-44e4-a75c-b6fdf479c3f0%40googlegroups.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALEm6wSDPeB5WsAtexme5tKSZwoNVUUege9OcYOvSR66pc3F3Q%40mail.gmail.com.