Reputation: 1101
I am designing a Jenkins CICD pipeline at my organization and I have a following question.
I am from a devops team that controls the Jenkins pipeline for multiple development teams. I basically want to write a Jenkins file with multiple stages that can be run by multiple teams. I understand that this Jenkins file can be checked into the Gitrepo of each team and it can invoke the complete pipeline as soon as the changes are done to the code repo.
To make sure that this JenkinsFile is maintainable and for any future changes to this Jenkins file I dont have to ask all the various teams to update this file in their Gitrepo , I want to place this file at a central Gitrepo that is controlled by my team.
Is it possible to invoke this Jenkins file from different Gitrepos? Any examples?
Upvotes: 4
Views: 10159
Reputation: 1037
To answer you question yes it is possible. To achive it approach has to be changed (i.e) there are no straight forward configuration available up to my understanding.
checkout scm:http://github.org.net/${JOB_NAME}.git
, here url is built using jenkins job name.Upvotes: 1
Reputation: 1101
Here is how I could do it:
My Base repo simply called a remote repo like this :
#!/usr/bin/env groovy
def jenkinsFile
stage('Loading Jenkins file') {
jenkinsFile = fileLoader.fromGit('testjenkinsstuff/cicd/testMyPipeline', 'https://github.myorg.com/user/testjenkinsstuff.git', 'master', null, '')
}
jenkinsFile.start()
Upvotes: 11