0

So I am trying to first write the output of a shell script command into a temporary file and then trying to read it and print the output. ( I'm doing this because I'm working with a very old Jenkins version and it has old/missing plug-ins)

Here is what Im doing-->

def BRANCH_REV = sh(returnStatus: true, script: " svn info \$url | grep 'Last Changed Rev' | awk '{ print \$4; }'  > output.txt")
  
def output = readFile('output.txt').trim()
def lines = output.readLines()

But I keep getting following error-->

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods readLines java.lang.String

Please help any suggestions are highly appreciated

samkraken
  • 31
  • 1
  • 8
  • search for `org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod` over the stackoverflow/internet – daggett Feb 16 '22 at 16:37
  • I know most of the solutions are suggesting to approve the in-script approvals. But that did not solved my issue I still keep getting this error. – samkraken Feb 16 '22 at 16:40
  • https://stackoverflow.com/questions/38276341/jenkins-ci-pipeline-scripts-not-permitted-to-use-method-groovy-lang-groovyobject – daggett Feb 16 '22 at 17:02
  • Thank you sooo much – samkraken Feb 16 '22 at 17:09

0 Answers0