0

I'm trying to create a Jenkins scripting pipeline that will hold a series of function that test some components that are being built from other pipelines. My idea is to have this collection of test functions in the same pipeline so they can share common functions and it's easy to maintian but on the other hand, each test can be individually called by the build pipelines.

All of our current pipelines are declarative. The How to invoke a jenkins pipeline A in another jenkins pipeline B question shows how to invoke a scripting pipeline from another scripting pipeline or how to do the same between two declarative pipelines. But how can I import and run a function from a scripting pipeline from a declarative pipeline?

I'm trying to solve the following problem: my company uses Jenkins to build several embedded components. We have automated tests for testing each member of those components, so the structure goes something like this:

Jenkins pipeline for component A
   |
   |- member 1
   |- member 2
Jenkins pipeline for component B
   |
   |- member 3
   |- member 4

I have tests for member 1, member 2, etc. The tests for each member of the same component are very similar. So my idea is to create a scripting pipeline that would offer a test_members_component_A and test_members_component_B, so test_members_component_A can be called from the component A pipeline and test_members_component_B can be called from the other pipeline.

Is this a good solution?

Leonardo
  • 1,533
  • 17
  • 28
  • you can technically declare a pipeline or function or script from a Shared Library. Have you tried with them? or is another use case? – jcmendez Mar 03 '21 at 16:51
  • Thanks for your reply! No, I didn't try creating a Shared Library. It seems a bit overkill at a glance, but I have a feeling that's the way to go. Thanks again! – Leonardo Mar 03 '21 at 17:01

0 Answers0