0

我的jenkins-shared-libraries结构是这样的:

vars
  |_mainPipeline.groovy
resources
src
 |_ com
     |_company
          |_utils.groovy
          |_data.groovy

实用程序.groovy:

package com.company;
def getCommitHash() {
  return "somestring"
}
return this

数据.groovy:

package com.company;
def utils = new com.company.utils()
def doSomeStuff() {
  def commitHash = utils.getCommitHash()
  // Do other stuff...
}
return this

mainPipeline.groovy: 数据.groovy:

def utils = new com.company.utils()
pipeline {
....
  def commitHash = utils.getCommitHash()
}

导入效果很好,但是,当我导入它时utils出现异常:mainPipelinedata.groovy

groovy.lang.MissingPropertyException: No such property: utils for class: groovy.lang.Binding

utils里面怎么用data?谢谢。

4

0 回答 0