Case 1
In the below code,
def url = "${BUILD_URL}console".toURL()
def consoleOutput = url.getText('utf-8')
Groovy script does not allow to use the syntax toURL()
:
Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods toURL java.lang.String. Administrators can decide whether to approve or reject this signature.
Error cause: org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods toURL java.lang.String
Case 2
Another approach:
print "${BUILD_URL}console"
def data = readFile("${BUILD_URL}console")
which gives error:
java.nio.file.NoSuchFileException: /app/jenkins/workspace/../folder/https:/xxxx.yy.zz.cccc.cloud/job/a/b/job/67/console
after the output:
https:/xxxx.yy.zz.cccc.cloud/job/a/b/job/67/console
How to get the contents of Jenkins build output?