How to refactor common Jenkins JobDSL code?

后端 未结 1 1001
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 04:50

I have the following JobDSL spec:

job {
  steps {
    gradle(\'generateLock saveLock\', \'-PdependencyLock.includeTransitives=true\', true) { node ->
      no         


        
相关标签:
1条回答
  • The curly brackets form a Groovy closure. Each closure has a delegate object to which method calls are directed. And the delegate can be accessed via the delegate property. You can pass that delegate to the helper function to get access to it's methods.

    def gradlew(def context, String tasks, String options = '') {
      context.gradle(tasks, options, true) { node ->
        node / wrapperScript('${NEBULA_HOME}/gradlew')
      }
    }
    job {
      steps {
        gradlew(delegate, 'generateLock saveLock', '-PdependencyLock.includeTransitives=true')
        gradlew(delegate, 'check')
      }
    }
    
    0 讨论(0)
提交回复
热议问题