Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins shared library: what is the difference between functions in /vars folder and /src folders?

I have followed jenkins extending pipeline with shared libraries
it was mentioned that

The src directory should look like standard Java source directory structure. This directory is added to the classpath when executing Pipelines.

while the vars directory hosts scripts that define global variables accessible from Pipeline

Note: I am more curious about the difference in usage not in implementation.

like image 825
Monem Avatar asked Feb 09 '17 12:02

Monem


1 Answers

Ok, well, you can see some sample differences in usage by simply examining the samples on the Extending with Shared Libraries page that you've probably already seen. For instance, if you look for the "Zot.groovy" example, you'll see that the code that uses this has to "new" the "Zot" class. However, if you look at the "vars/acme.groovy" sample, you'll see that the user code doesn't have to "new" anything, because the global variable named "acme" exists to be referenced by the script.

There are other differences, but that's one simple contrast.

like image 187
David M. Karr Avatar answered Sep 28 '22 07:09

David M. Karr