这是我正在使用的 Jenkins 声明性管道的简化:
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()
}
}
}
}
}
}
为什么该行会def container = img.withRun()
生成此错误:
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.
......而def container = img.run()
没有?
withRun()
本来应该是首选,因为它的界面更干净,可以保证清理,但我不能以管理方式允许选定的脚本。