PUBLIC_DNS=$(aws ec2 describe-instances --region ${AWS_DEFAULT_REGION} --filters 'Name=tag:Name,Values=udapeople-backend-ec2-*' --query "Reservations[*].Instances[0].PublicDnsName" --output text)
echo ${PUBLIC_DNS}
curl -H "Content-Type: text/plain" \
-H "token: ${CIRCLE_WORKFLOW_ID}" \
--request PUT \
--data ${PUBLIC_DNS} \
https://api.memstash.io/values/public_dns
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
Exited with code exit status 2
CircleCI received exit code 2
your error isn't with Circle CI but with your curl command. The error message is saying it doesn't have a URL to which to PUT. I do see that you included a URL in your curl command, so maybe the problem is in your line endings. Try removing the line endings and run your circle CI job again. You can also try running the command from your local command line.
This is because memstash.io is not working as a website or webservice, there is no issue in your code , memstash is working as a memory-cache for CD jobs so you can find another CD caching service or you have a good option to use circle ci caching itself , try to search for circleCI docs
Related
I have a Kubernetes cluster on which is deployed a replica of this image (but it's not important for the sake of the question).
Now, in Powershell I need to perform one REST request against the pod. In particular I have to send a PUT request to the endpoint http://<POD_IP>:18681/PCCIS/V1/Service/Properties/Servers passing this JSON payload:
{"servers":[{"port":"18682","address":"10.244.1.29"}]}
What I was trying to do is perform this action from within a curlimages/curl pod, just to be able to reach the pod's network. This is my attempt:
$PrizmDocPodIP="10.244.1.29"
$JsonPostBody='{"servers":[{"port":"18682","address":"10.244.1.29"}]}'
$cmd = "curl -i --header 'Content-Type: application/json' --request PUT --data '$JsonPostBody' http://$($PrizmDocPodIP):18681/PCCIS/V1/Service/Properties/Servers"
kubectl run -i --tty --rm curl --image=curlimages/curl --restart=Never "$cmd"
Unexpectedly, the command output this error:
curl: (3) nested brace in URL position 82:
curl -i --header 'Content-Type: application/json' --request PUT --data '{servers:[{port:18682,address:10.244.1.29}]}' http://10.244.1.29:18681/PCCIS/V1/Service/Properties/Servers
As you can see, the problem I have is that the string command I pass is not interpreted the right way and moreover the payload loses all the doublequotes of the JSON, that are important for the curl command to propertly work.
One another test I made is with this command (the echo is used to show what the sh command really would execute)
kubectl run -i --tty --rm curl --image=curlimages/curl --restart=Never -- sh -c "echo $cmd"
And the output is
curl -i --header Content-Type: application/json --request PUT --data {servers:[{port:18682,address:10.244.1.29}]} http://10.244.1.29:18681/PCCIS/V1/Service/Properties/Servers
Showing that the cmd Powershell variable loses its doublequotes when passed to kubectl run
What should be the right syntax to pass the $cmd command as is (preserving all its quotes and chars)?
I found the solution after some searching and trials.
First, I have to escape the double quotes in the $JsonPostBody variable.
$PrizmDocPodIP="10.244.1.29"
$JsonPostBody='{\"servers\":[{\"port\":\"18682\",\"address\":\"10.244.1.29\"}]}'
The other error is that the curlimages/curl Docker image executes the kubectl run arguments as the curl's arguments, so I don't have to use the curl command:
kubectl run -i --tty --rm curl --image=curlimages/curl --restart=Never -- -i --header 'Content-Type: application/json' --request PUT --data $JsonPostBody http://$($PrizmDocPodIP):18681/PCCIS/V1/Service/Properties/Servers
This outputs
HTTP/1.1 200 OK
[1mDate[0m: Wed, 08 Jul 2020 13:23:30 GMT
[1mConnection[0m: keep-alive
1mContent-Length[0m: 0
I'm trying to download the latest snapshot dependency of a zip on Nexus 3 (version 3.22.1-02) from a command line using curl:
curl -u username:password -X GET "https://mynexusserver/service/rest/v1/search/assets/download?sort=version&repository=snapshotsrepo&maven.groupId=mygroup&maven.artefactId=myartefact&maven.extension=zip" -H "accept: application/json" -o myartefact.zip
This request is similar to this example: http://help.sonatype.com/repomanager3/rest-and-integration-api/search-api#SearchAPI-DownloadingtheLatestVersionofanAsset but no result is returned, myartefact.zip is empty.
However with the same URL, my artefact is downloaded from a web browser or with gradle.
With curl the following command line is working fine, returning the list of all snapshot versions of my artefact:
curl -u username:password -X GET "https://mynexusserver/service/rest/v1/search/assets?sort=version&repository=snapshotsrepo&maven.groupId=mygroup&maven.artefactId=myartefact&maven.extension=zip" -H "accept: application/json" -o myartefact.zip
Downloading the artefact directly is working fine as well with a command line like:
curl -u username:password "https://mynexusserver/repository/snapshotsrepo/mygroup/batchfactory/myversion-SNAPSHOT/myartefact-myversion-mytimestamp.zip" -H "accept: application/json" -o myartefact.zip
Verbose logs (-v option) show the artefact is found (I get HTTP/1.1 302 Found message) but nothing is downloaded.
Using wget doesn't work any better, I can't even query the list of snapshot version of the artefact.
Am I missing something?
Thanks #Zeitounator, after adding "-L" the command line works fine. Considering code 302 this feels obvious now...
Nexus documentation should also probably be updated to add the "-L" option.
Please advise, how to remove files inside a container using the Docker API?
I have tried to do it this way, but it doesn't work
curl --location --request POST 'http://192.168.1.55:5555/containers/{id}/exec' \
--header 'Content-Type: application/json' \
--data-raw '{
"Cmd": [
"/bin/sh",
"-c",
"'rm -rf /files/*'"
]
}'
According to the Docker API doc "To exec a command in a container, you first need to create an exec instance, then start it. These two API endpoints are wrapped up in a single command-line command, docker exec." In this way, after getting the response you must run new POST request /exec/{id}/start
I want to create a bitbucket comment after finishing my bamboo build. Unfortunately my rest call didnt work. ALso Im getting no response.
Am I missing something?
curl -u "USER:PASSWORD" -X POST -d '{"body": "Your Message to Comment"}' "http://URL/2.0/repositories/OWNER/REPO/pullrequests/ID/comments"
Execute the following command:
curl -u "USER:PASSWORD" --request POST --data '{"text": "YOUR-COMMENT"}' "BITBUCKET-SERVER/rest/api/1.0/projects/PROJECT/repos/REPO/pullrequests/ID/comments"
I am trying to delete a pull-request from bitbucket. I am using the following command,
curl -v -u {username}:{password} -X DELETE -H "Content-Type:application/json" https://{bitbucket.com}/rest/api/1.0/projects/{project_name}/repos/{repo_name}/pull-requests/{pull-request_id}
but the command fails with an error code 400. Please find the error:
{"errors":[{"context":null,"message":"No content to map to Object due to end of input","exceptionName":"java.io.EOFException"}]}.
I think I am missing something in the rest url. Please help me to resolve the issue. Thanks in advance
You need to pass the "version" of the pull-request (remember that the pull-request version starts in 0). Add the "-d #-" option to send the version in a here-document.
curl -v -u {username}:{password} -d #- -X DELETE -H "Content-Type:application/json" https://{bitbucket.com}/rest/api/1.0/projects/{project_name}/repos/{repo_name}/pull-requests/{pull-request_id} <<EOF
{
"version": {version}
}
EOF