0

I have a Jenkins pipeline step where I extract the build number from an INI file.

This answer shows how to do this using a Properties object - but for this to work, I have to disable "Use Groovy Sandbox".

How can I solve this in a "Groovy Sandbox" approved manner?

Edit: I would prefer to use methods that are approved out of the box, rather than modifying a whitelist. So this question is really asking how to solve the problem with methods that are already allowed.

Community
  • 1
  • 1
Ola Eldøy
  • 5,720
  • 7
  • 49
  • 82

1 Answers1

1

Depends on how the Sandbox is implemented / what the Sandbox allows. If you are using the https://wiki.jenkins-ci.org/display/JENKINS/Script+Security+Plugin, then there is a whitelist and a blacklist of methods you might and might not use. Either add the calls you need to the whitelist by approving them on the according approval page or find a way to solve the task with the methods that are allowed.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • Well, then try to solve it with the default whitelist. SO questions like "write me some code please" are off-topic. Try to write the code yourself and then come back to SO if you have a concrete problem you need help with. If the mentioned plugin is the one you are useing, you can find the whitelist at https://github.com/jenkinsci/script-security-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/scriptsecurity/sandbox/whitelists. Basically spoken, you said this is an INI file, so the `Properties` class will not work anyway. You have the content, so just split it by newline and go on. – Vampire Apr 20 '17 at 09:34
  • Point taken, and thanks for digging up the default whitelist location. – Ola Eldøy Apr 20 '17 at 10:52