Pass the data thru variable using curl command

26 views
Skip to first unread message

panneerrselvam natarajan

unread,
Jan 20, 2019, 11:55:17 PM1/20/19
to Jenkins Users
Hi All,

I am using Jenkins for API Testing in Pega Environment.  I can send and receive response thru PostMan and SOAPUI and working fine.

But I want to automate using Jenkins Pipeline.

Please do let me know, How do i send the data/variable thru CURL command in pipeline. I sent the data but not displayed any error message and not getting any response also

I am sending the data which include special charector along with Data. Please do let me know the format.

Regards
Panner

David Karr

unread,
Jan 21, 2019, 11:50:19 AM1/21/19
to jenkins...@googlegroups.com
I suggest you show us exactly what you're doing, what the result is, and what you expected. Exactly.


Regards
Panner

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ad16f4d1-c745-442a-90df-b2b73b73e03f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Panneer

unread,
Jan 21, 2019, 11:18:28 PM1/21/19
to Jenkins Users
Hi David,

My request is here below:-

def status = "curl -s --max-time 30 POST 'https:url'" -H "Content-type: application/json" -d {"DeAppRulesList": [{"Applion":"02.01.02","Applime":"REFW"},{"Applion":"01.01.01","Applime":"ATP_Branch"},{"Applion":"01.06.07","Applime":"Temp_FW"}]}'

No error and no response received.

Regards
Panneer

Ramanathan Muthaiah

unread,
Jan 22, 2019, 12:42:27 AM1/22/19
to Jenkins Users
My request is here below:-

def status = "curl -s --max-time 30 POST 'https:url'" -H "Content-type: application/json" -d {"DeAppRulesList": [{"Applion":"02.01.02","Applime":"REFW"},{"Applion":"01.01.01","Applime":"ATP_Branch"},{"Applion":"01.06.07","Applime":"Temp_FW"}]}'

No error and no response received.

Start simple, then expand. Also, I presume you should adjust the cmd, to be like, "curl . . . -X POST".

Avoid using "-s" option during the initial trials. man curl is your best help.

Remember, getting curl working from CLI and in an automated env like Jenkins involves several iterations, depending on the complexity (speaking from my personal experience).

/Ram 

David Karr

unread,
Jan 22, 2019, 12:53:22 PM1/22/19
to jenkins...@googlegroups.com
On Mon, Jan 21, 2019 at 8:18 PM Panneer <pann...@gmail.com> wrote:
Hi David,

My request is here below:-

def status = "curl -s --max-time 30 POST 'https:url'" -H "Content-type: application/json" -d {"DeAppRulesList": [{"Applion":"02.01.02","Applime":"REFW"},{"Applion":"01.01.01","Applime":"ATP_Branch"},{"Applion":"01.06.07","Applime":"Temp_FW"}]}'

No error and no response received.

Well, if these are ALL the lines involved in making this call, then the answer is obvious.  All you're doing is setting a string here with a command line to use.  You're not actually executing this command.


Regards
Panneer


On Monday, January 21, 2019 at 9:50:19 AM UTC-7, David Karr wrote:

On Sun, Jan 20, 2019 at 8:55 PM panneerrselvam natarajan <pann...@gmail.com> wrote:
Hi All,

I am using Jenkins for API Testing in Pega Environment.  I can send and receive response thru PostMan and SOAPUI and working fine.

But I want to automate using Jenkins Pipeline.

Please do let me know, How do i send the data/variable thru CURL command in pipeline. I sent the data but not displayed any error message and not getting any response also

I am sending the data which include special charector along with Data. Please do let me know the format.

I suggest you show us exactly what you're doing, what the result is, and what you expected. Exactly.


Regards
Panner

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ad16f4d1-c745-442a-90df-b2b73b73e03f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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-use...@googlegroups.com.

Panneer

unread,
Jan 22, 2019, 1:29:00 PM1/22/19
to Jenkins Users

Hi Ram,

Thanks for your response,

Are you using any editor to validate before post it in pipeline? I am new.. can you suggest


Regards
Panneer

N Panneerrselvam

unread,
Jan 22, 2019, 2:11:27 PM1/22/19
to jenkins...@googlegroups.com
Thanks David
I am executing in next line
Def respo1 = sh.script: second_reg , returnstdout : true


N Panneerrselvam

unread,
Jan 22, 2019, 2:15:37 PM1/22/19
to jenkins...@googlegroups.com
Def sresponse = sh scripts: status, return srdout: true

David Karr

unread,
Jan 22, 2019, 6:24:16 PM1/22/19
to jenkins...@googlegroups.com
I suggest you add "-v" to the curl command-line options and then print the "sresponse" variable.

Björn Pedersen

unread,
Jan 23, 2019, 8:41:41 AM1/23/19
to Jenkins Users


Am Dienstag, 22. Januar 2019 05:18:28 UTC+1 schrieb Panneer:
Hi David,

My request is here below:-

def status = "curl -s --max-time 30 POST 'https:url'" -H "Content-type: application/json" -d {"DeAppRulesList": [{"Applion":"02.01.02","Applime":"REFW"},{"Applion":"01.01.01","Applime":"ATP_Branch"},{"Applion":"01.06.07","Applime":"Temp_FW"}]}

Carefully check all the quotes! They seem to be incorrect.
Dump the content of status both with
 echo status

and
 sh "echo $status"

to check that all inner quotes survive as you want them to.

 

Panneer

unread,
Jan 23, 2019, 10:46:12 AM1/23/19
to Jenkins Users

Hi All,

Thanks for your response.

I tried with V also.. Now i tried with less data , but still i am not able see the response.. The complete my request is here below:-
def fresponse = '''\{"DependentApplctnRulesList": [ { "pyVersion": "01.06.07", "pyName": "Temp_PFW" }]}''' 
def second_Req = "curl -v --max-time 30 POST 'https://url'" + " -H " + "\"Content-type: application/json\"" + " -d " + '\'' + fresponse + '\''      
def Sresponse = sh script: second_Req, returnStdout: true
echo "Final request  " + second_Req

The above fresponse works fine with postman and SOUPUI.

'
Regards
Panneer

panneerrselvam natarajan

unread,
Jan 30, 2019, 11:28:06 PM1/30/19
to 'Nakul Khargonkar' via Jenkins Users
Thanks David.

-v option helped me to fix the issue.

Regards
Panneerr


Reply all
Reply to author
Forward
0 new messages