What is the difference between a step and a global variable with properties?
IntermediateConceptShared libraries
Answer
A vars/ file without call() acts as a namespace object: vars/cfg.groovy with def registry() { 'docker.io/devopsshack' } is used as cfg.registry(). Global variables cannot hold state reliably between calls, because each access may get a new instance; do not use fields to store build data. Use env or return values instead.
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?IntermediateHow do classes in `src/` call pipeline steps?IntermediateWhat is `libraryResource` used for?IntermediateWhat are the ways to load a library in a Jenkinsfile?Intermediate