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

Hi @rschuntigit,

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.

3 Likes