0

My jenkins-shared-libraries structure is this:

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

utils.groovy:

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

data.groovy:

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

mainPipeline.groovy: data.groovy:

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

Importing utils on the mainPipeline works great, however, when I import it on data.groovy I get an exception:

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

How do I use utils inside data? Thanks.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Moshe
  • 4,635
  • 6
  • 32
  • 57

0 Answers0