@Library('utils') _ log.info 'Starting' log.warning 'Nothing to do!' 

Declarative Pipeline does not allow global variable usage outside of a script  directive (JENKINS- 42360). 

@Library('utils') _ pipeline { agent none stage ('Example') { steps { script { ① log.info 'Starting' log.warning 'Nothing to do!' } } } } 

① script  directive required to access global variables in Declarative Pipeline. 

## NOTE 

## WARNING 

## Defining custom steps 

A variable defined in a shared library will only show up in Global Variables Reference  (under Pipeline Syntax ) after Jenkins loads and uses that library as part of a successful Pipeline run. 

Avoid preserving state in global variables Avoid defining global variables with methods that interact or preserve state. 

Use a static class or instantiate a local variable of a class instead. 

Shared Libraries can also define global variables which behave similarly to built-in steps, such as sh or git . Global variables defined in Shared Libraries must  be named with all lower-case or "camelCased" in order to be loaded properly by Pipeline. [18: gist.github.com/rtyler/ e5e57f075af381fce4ed3ae57aa1f0c2] 

For example, to define sayHello , the file vars/sayHello.groovy  should be created and should implement a call  method. The call  method allows the global variable to be invoked in a manner similar to a step: 

