Created
April 16, 2018 04:33
-
-
Save sirius2k/e280089451e076070bdb4dae38c32051 to your computer and use it in GitHub Desktop.
Read json in Jenkins pipeline groovy script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to read json response and print