Jenkinsfile – calling multiple groovy scripts

We have our shared libraries on gitlab called mainlibrary and it has a lot of groovy files.

Example in mainlibrary gitlab repo we have the following files.

startup_pipeline.groovy
cleanup_pipeline.groovy

In one of our Jenkins job we need to include multiple groovy files in the Jenkinsfile. Is this possible?

This is how the Jenkinsfile looks like:

@Library('mainlibrary')_
startup_pipeline(email:'example@example.com')

Can I include the second groovy function file into this Jenkinsfile like this?

@Library('mainlibrary')_
startup_pipeline(email:'example@example.com'),
cleanup_pipeline(email:'example@example.com')

Answer

Yes, according to the official docs you can include as many custom steps (each in their own .groovy file) in your shared library as you like.

Attribution
Source : Link , Question Author : John Doe , Answer Author : jayhendren

Leave a Comment