Skip to content

Instantly share code, notes, and snippets.

@sirius2k
Created April 16, 2018 04:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirius2k/e280089451e076070bdb4dae38c32051 to your computer and use it in GitHub Desktop.
Save sirius2k/e280089451e076070bdb4dae38c32051 to your computer and use it in GitHub Desktop.
Read json in Jenkins pipeline groovy script
/*
example json text in dir/input.json
{ "key": "value" }
*/
def props = readJSON file: 'dir/input.json'
assert props['key'] == 'value'
assert props.key == 'value'
def props = readJSON text: '{ "key": "value" }'
assert props['key'] == 'value'
assert props.key == 'value'
def props = readJSON text: '[ "a", "b"]'
assert props[0] == 'a'
assert props[1] == 'b'
@AnshumanPanda111
Copy link

how to value of key i.e how to know what key is?

@gnanasekarsvmx
Copy link

how to read json response and print

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment