Here is a simplification of Jenkins declarative pipeline I'm working with:
pipeline {
agent any
stages {
stage("demo") {
steps {
script {
def co_url = 'https://bitbucket.company.com/scm/demo/prj.git'
checkout( [$class: 'GitSCM',
branches: [[name: 'my_branch']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory',
relativeTargetDir: 'prj']],
submoduleCfg: [],
userRemoteConfigs: [[url: co_url]]] )
dir(WORKSPACE + "/prj") {
def img = docker.build("foo:1.0.0", "--target fubar .")
def container = img.withRun()
}
}
}
}
}
}
Why does the line def container = img.withRun()
generate this error:
Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (org.jenkinsci.plugins.docker.workflow.Docker$Image withRun). Administrators can decide whether to approve or reject this signature.
...whereas def container = img.run()
does not?
withRun()
would have been preferanle because of its cleaner interface to guarantee cleanup, but it is not an option for me to administratively allow selected scripts.