Reputation: 33
Is there a way to use a global pipeline library when defining an Active Choices Reactive Parameter in Jenkins?
I have added a global pipeline library in Jenkins, let's say PipelineLibrary
, and I am able to use it successfully in my pipelines by loading it with @Library('PipelineLibrary') _
. In this library I have a global function foo.bar()
, which I would like to use also in the Groovy Script box when adding an Active Choices Reactive Parameter to several of my jobs.
So I would like to have something like this in the Groovy Script box of that parameter:
// Somehow take into use PipelineLibrary
return foo.bar();
What is the correct syntax to load the library here? Or is it even possible? If not, is there some other way to share the Groovy script to several places without just copy-pasting the code in the GUI?
Upvotes: 1
Views: 1683
Reputation: 31
Actually, I have found a way to do it. You just need to need to define new global variables in your Jenkinsfile and their values will be from the Shared library respectfully. Afterwards you can use the new defined global variables in your Active Choice Parameter script.
Upvotes: 1