Jenkins Pipeline Groovy Script and JSON

10,437 views
Skip to first unread message

Sami Jaber

unread,
Aug 10, 2016, 4:32:06 AM8/10/16
to Jenkins Users
Hi all,

Is there any way to parse JSON string in the Jenkinsfile groovy script to meet Jenkins security requirements and avoid the famous exception => org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified method groovy.json.JsonSlurper parse java.lang.String

Just want to do :
def jsonStream = readFile('jsonFile')
echo 'Version ' + jsonStream.version 

Thanks for your answers or pointing me out right articles/guides

Sami

Baptiste Mathus

unread,
Aug 10, 2016, 8:17:29 AM8/10/16
to jenkins...@googlegroups.com

Salut Sami :)

Cannot check it right now, but did you have a look under the /scriptApproval page?

Though I seem to remember the 'unclassified' ones sometimes don't appear there.

If you can see it, you have to approve it. This is a security measure to not give access to the whole Jenkins instance/VM to all pipeline scripts.

Cheers


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b0412d4b-c461-43ee-921d-277495be6760%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sami Jaber

unread,
Aug 10, 2016, 9:06:33 AM8/10/16
to jenkins...@googlegroups.com

Salut Baptiste !

Nothing appears under approval page, the textarea is always empty.
To bad that there is no "sandbox approved" for such task.
Sami

You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/HmN37KoLFQs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANWgJS6oYQCuWLASjRPFi9h8wxCKNBJ7RBrkqmsx%3DCfHvgaDSA%40mail.gmail.com.

Łukasz Zachulski

unread,
Aug 11, 2016, 2:09:54 AM8/11/16
to Jenkins Users
Please check SO thread for details regarding JSON file parsing in Jenkinsfile, http://stackoverflow.com/q/37864542/6128602.
Reply all
Reply to author
Forward
0 new messages