How to use curl command to get value of consul key from https end point from jenkins bash script

743 views
Skip to first unread message

RSriv

unread,
Jun 21, 2020, 10:01:07 PM6/21/20
to Consul

I am using Jenkin job to automatically update the consul key using https endpoint. The syntax I am using to update the consul key using curl command in bash script is below which works fine:-


curl -f -s --show-error "https://example.com/a/b/c?AdminKey=xxxxx&token=yyyyyyy&value=nnn”. (Here key is -->a/b/c)


The above command updates value of consul key "a/b/c" with “nnn”


Now I want to fetch the value of same key in a variable then how I can fetch it using Jenkins job (bash script and curl command)  similar to what I have mentioned above?


Note: I have tried curl command such as variable=`curl -f -s --show-error "https://example.com/a/b/c?AdminKey=xxxxx&token=yyyyyyy”` but it is not working.


Thanks

Blake Covarrubias

unread,
Jun 28, 2020, 11:37:18 PM6/28/20
to consu...@googlegroups.com
Hello,

I saw you posted this question on both the Discuss forums [1] and StackOverflow [2]. I provided answers there, but wanted to close the loop on this thread as well in case you did not see those replies.

You can update a key using this syntax.

curl --request PUT --fail --silent --show-error "http://localhost:8500/v1/kv/a/b/c?token=<token>" --data 'nnn'

The value can then be retrieved and stored in a variable using this command.

export VARIABLE=$(curl --fail --silent --show-error "http://localhost:8500/v1/kv/a/b/c?token=<token>&raw")

See https://www.consul.io/api-docs/kv for more info on the supported arguments for these API calls.

Best,
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/consul/issues
Community chat: https://gitter.im/hashicorp-consul/Lobby
---
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/consul-tool/2b965abb-2b10-4602-9a77-f9a18f9a3853o%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages