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

fengyu · 2018年08月01日 · 最后由 fengyu 回复于 2024年01月09日 · 1020 次阅读
   // 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

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册