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')
More on Shared libraries
What is the directory structure of a shared library?BeginnerHow does a `vars/` global step work?BeginnerWhat goes in `src/` and how is it used?IntermediateWhat is `libraryResource` used for?IntermediateWhat are the ways to load a library in a Jenkinsfile?IntermediateGlobal vs folder-level vs ad hoc libraries: what is the security difference?Advanced