DEV Community

Discussion on: Centralise Jenkins Pipelines configuration using Shared Libraries

Collapse
 
abdelhegazi profile image
Abdel Hegazi

Hi Juan,

Thanks a lot for this post, really simple and straight forward.

I have a question related to this, as relying much on the shared library is an amazing way for having a very simple Jenkinsfile in each of my services which is cool, but that means any change in this shared library can break everything.

How to test the pipeline "shared library" before merging any change in my master branch that is called by every other service calling this pipeline, in another way how to test any changes before applying them to void breaking everything?

I tried to follow the JenkinsPipelineUnit on github but I really didn't get it well, can you explain it if you have done this before?

Thanks a lot

Collapse
 
jalogut profile image
Juan Alonso

Hi Abdel,
What I usually do is to add my changes in a new brach of the shared library. Then I take one project and I modify its jenkinsfile to use that new branch. You can do that like that:

@library("your-library-name@BRANCH_NAME") _

After testing that everything works ok, I merge the library changes in master.

Would that work for you?

Collapse
 
abdelhegazi profile image
Abdel Hegazi

HI Juan,

Thanks again for your reply, but this is actually what I do in the mean time passing my own branch of the shared library repo, but seems to be very manual to us especially wish a really complex pipeline.

What I meant in my question is can we do any sort of unittest to the pipeline before merging to the shared library master branch

Things like cucumber, maven ...etc have you done any similar testing before for the sharedlibrary repo before as I can see your way is very manual testing and I wish if you had done any automated testing for the pipeline with the shared library.

Again Thanks a lot Juan
Abdel

Thread Thread
 
jalogut profile image
Juan Alonso

Hi Abdel,

No, I do not do any automated tests for the pipeline code itself. If you find a convenient way to do it, I’d love to know more. I think there is something about testing the pipeline code in the following video. Here is the link in case it helps: