Reputation: 227
I used jq -r '.version' package.json
command to filter the version from package.json file using the terminal.
Can we use jq
command in Jenkins shell without locally installing it?
Upvotes: 2
Views: 11881
Reputation: 15235
Instead of using "jq", use the groovy.json.JsonSlurper
class to parse the same output that "jq" can parse.
If "jsonStr" is a string variable with legal json content, here's an example using this:
def stuff = new JsonSlurper().parseText(jsonStr).stuff
This will get the "stuff" property in the json string and assign it to the "stuff" variable.
Upvotes: 3
Reputation: 4168
No, in the shell
build step, you can only execute commands which are available to the shell therefor you have to install jq
on your system and it must be accessible by jenkins.
Upvotes: 1