CI/CD Scaling for Multiple Projects

While building the Jenkinsfile.groovy for a single project is straightforward, we want to share the logic across multiple C# projects.

I won’t go into the details as I did with my other posts about the process I went through. I moved the logic for Jenkinsfile.groovy into a Jenkins shared library, which is publicly available at Jenkins Library Sample.

Adding a Shared Library to Jenkins

I updated the configuration for my multi-branch pipeline to include the shared library:

Note: JenkinsLibrarySample was renamed to jenkins-shared-library-groovy when searching github.

This updates the Jenkinsfile.groovy to:

@Library('JenkinsLibrarySample')_

import org.sample.jenkins.CSharpBuilder

CSharpBuilder builder = new CSharpBuilder(this)

builder.run()

This also moves quite a bit of the hardcoded configuration I had into the Configuration.json file allowing much finer control over necessary information for a build. This is documented in the Jenkins Library Sample readme.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.