Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there a sometimes a trailing underscore in the Pipeline @Library() syntax

Tags:

Why does the @Library() call require the trailing _ (underscore) character at least in some cases? e.g. @Library('foobar-library@foobranch') _

That seems completely superfluous to me but maybe there's a good explanation?.

like image 530
Mad Max Avatar asked Dec 18 '17 19:12

Mad Max


People also ask

What is Jenkins pipeline library?

A shared library in Jenkins is a collection of Groovy scripts shared between different Jenkins jobs. To run the scripts, they are pulled into a Jenkinsfile. Each shared library requires users to define a name and a method of retrieving source code.

How does Jenkins define pipeline?

Jenkins Pipeline (or simply "Pipeline") is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins. A continuous delivery pipeline is an automated expression of your process for getting software from version control right through to your users and customers.

What is @NonCPS?

The @NonCPS annotation is useful when you have methods which use objects which aren't serializable. Normally, all objects that you create in your pipeline script must be serializable (the reason for this is that Jenkins must be able to serialize the state of the script so that it can be paused and stored on disk).


1 Answers

Based on this Jenkins blog

After configuring Jenkins so that it can find the shared library repository, we can load the shared library into our pipeline using the @Library('') annotation.

Since Annotations are designed to annotate something that follows them, we need to either include a specific import statement, or, if we want to include everything, we can use an underscore character as a placeholder.

like image 60
rohitmohta Avatar answered Oct 31 '22 19:10

rohitmohta