Reputation: 33
I have shell script to run from Jenkins. First step generates token. But when executed from Jenkins, it gives connection error
Jenkins here is Linux server
Command:
curl -w -X POST $URL -H Content-Type:application/x-www-form-urlencoded -H Content-Length:1045 -H Authorization:OAuth2 --data '{"grant_type":"password", "username":"User","password":"pwd"}' --write-out token
Error:
curl: (6) Could not resolve host: POST; Unknown error
100 88 0 0 0 88 0 0 --:--:-- 0:02:01 --:--:-- 0
100 88 0 0 0 88 0 0 --:--:-- 0:02:02 --:--:-- 0
100 88 0 0 0 88 0 0 --:--:-- 0:02:02 --:--:-- 0
curl: (56) Recv failure: Connection reset by peer
Build step 'Execute shell' marked build as failure
Upvotes: 1
Views: 13890
Reputation: 943579
You failed to provide a value with -w
.
This means that -X
is taken that value instead of being a switch in its own right.
That means that POST
is not taken as the value to the -X
switch, so it is taken as the URL instead.
Remove -w
or pass it a value.
Upvotes: 1