I'm trying to figure out the best way to have multiple groovy projects in same repo, this might not be the best solution, welcome to others input.
Background
We have an in house use of Jenkinsfiles for our jenkins clusters. Devs can configure what commands, variables, node labels etc to use with a config yaml. This is to restrict what they can run because that is a requirement within this space and they really only need a few standard items but enough variation it's hard to make 1 version.
The pipeline is run through the github org jenkins plugin, clones the pipelines repo first, then clones the repo for the actual code. The config is then interpreted with a jenkinsfile and our groovy files/package. This reads then executes the requested commands.
The existing jenkinsfile and groovy is not clean and has had stuff added over time. We are going to introduce versioned pipelines with a new config yaml specification and improved features. The aim is to have both the old and new (plus future) major pipelines versions in the same repo but separated. They need to be in the same repo because of how jenkins github plugin uses this pipelines repo.
The basic layout of the repo
+-- resources
| +-- env_vars.json
+-- src
| +-- com
| +-- company
| +-- utils
| +-- Pipeline.groovy
| +-- Helper.groovy
+-- vars
| +-- dockerManager.groovy
+-- Jenkinsfile
Something along the lines of the following is desirable, each version separated (there would be some code duplication which we accept). The jenkinsfiles in each version would be replaced with a groovy class and the root level jenkinsfile be a wrapper to select which version to execute this
+-- v1
| +-- resources
| +-- env_vars.json
| +-- src
| +-- com
| +-- company
| +-- utils
| +-- Pipeline.groovy
| +-- Helper.groovy
| +-- vars
| +-- dockerManager.groovy
| +-- v1.groovy
+-- v2
| +-- resources
| +-- env_vars.json
| +-- src
| +-- com
| +-- company
| +-- utils
| +-- Pipeline.groovy
| +-- Helper.groovy
| +-- v2.groovy
+-- Global.groovy
+-- Jenkinsfile
I'm also fine with a version to do away with the package aspect if that would make sense in this case. My groovy is not the best so any input would be greatly appreciated, many thanks.
question from:
https://stackoverflow.com/questions/65652373/multiple-groovy-projects-package-in-the-same-repo-jenkins-pipelines 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…