持续集成 如何理解 pipeline Shared Libraries 中闭包和控制反转的代码?

fengyu · August 01, 2018 · Last by fengyu replied at January 09, 2024 · 2042 hits
   // vars/buildPlugin.groovy
  def call(body) {
      // evaluate the body block, and collect configuration into the object
      def config = [:]
      body.resolveStrategy = Closure.DELEGATE_FIRST
      body.delegate = config
      body()
      // now build, based on the configuration provided
      node {
          git url: "https://github.com/jenkinsci/${config.name}-plugin.git"
          sh "mvn install"
          mail to: "...", subject: "${config.name} plugin build", body: "..."
} }
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body()

这几句如何理解?
附参考帖子:
http://wiki.jikexueyuan.com/project/groovy-introduction/domain-specific-languages.html

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up