Interview Prep/Jenkins/Shared libraries

How do classes in `src/` call pipeline steps?

IntermediateConceptShared libraries
Answer

Steps exist on the pipeline script object, not inside your class. Pass the script in and keep the class serializable.

package com.devopsshack
class Deployer implements Serializable {
  def steps
  Deployer(steps) { this.steps = steps }
  void rollout(String ns, String deploy) {
    steps.sh "kubectl -n ${ns} rollout status deploy/${deploy} --timeout=120s"
  }
}
new com.devopsshack.Deployer(this).rollout('shack-dev', 'shack-app')
All Jenkins questions Roadmap: Jenkins

More on Shared libraries