Remote File1.1Minimum Jenkins requirement: 2.176.1ID: remote-file
This pipeline enables definition of external Jenkins File from another repository for Multi Branch Pipelines. With this feature you can centralize Jenkins Files in another repository instead of putting within the code itself while still able to use Multi Branch Pipelines.
When it comes to adding new definitions/stages/steps or maintaining the Jenkins Pipeline Script for other reasons, you need to make all the changes within all branches or make changes in master branch and wait for other branches getting the update. For eliminating this you can used Jenkins Shared Library. However when you are in an large-scaled/enterprise environments with hundreds/thousands of developers with lots of repositories, you need to somehow protect the content/stability of the Jenkins Pipeline Scripts to avoid failures.
In this point Remote Jenkins File Plugin comes in. With this plugin you can define/set Jenkins files from another repository while still able to use Multi Branch Pipeline Project features. This way you will be able to centralize all Jenkins files in another repository where you can review or restrict changes and use Multi Branch Pipeline for multi branched repositories.
In summary, Using Multi Branch Pipeline Jobs with Remote Jenkins File Plugin you can;
- Centralize Jenkins Files in another repository
- Easily maintain
- Review or restrict changes
- Apply changes to all Pipelines in seconds
To use this Plugin first you need to install it from Jenkins Plugin Site, for details see Managing Plugins
After installing plugin for using the plugin you can follow the steps with examples below,
Assume that you have a project to build, named "MyCrazyProject", which is stored in repository https://github.com/aytuncbeken/MyCrazyProject.git
- Create a new repository for storing Jenkins files for your projects. For example, it is named "MyJenkinsLibrary" and stored in https://github.com/aytuncbeken/MyJenkinsLibrary.git
- Create a directory in this repository for your project. For example, create directory called "MyCrazyProject"
- Commit/Push your Jenkins File, named "Jenkinsfile" under this directory
- Open you Jenkins and create a new Mult iBranch Project. For example, named "MyCrazyProject Job"
- Add Source for your project to build. For example, fill information for "MyCrazyProject"
- In the "Build Configuration", change "Mode" to "by Remote Jenkins File Plugin". You will see new SCM definition is occurred under.
- Define your script path. For example, it will be "MyCrazyProject/Jenkinsfile"
- Define your SCM for Jenkins file. For example, it will be the repository https://github.com/aytuncbeken/MyJenkinsLibrary.git
- Click Save.
- In the "Scan Multi Branch Pipeline Log", you will see logs "Ignoring Jenkins file checking in Source Code SCM" which is normal as this plugin ignores Jenkins files in your repository and inject Jenkins File from other repository which you stored your Jenkins files.
You can see screenshot of example definition.
For filtering branches in the project, you can use "Filter by name" feature.
To create issue you can logon Jenkins Jira and create issue with component names "remote-file-plugin"
See release notes in plugin GitHub page.