Motivation
Concept of Pipeline plugins it requires save Jenkinsfile in root repository. Workflow Multibranch Plugin extend this idea to build all branches in repository. This is very easy for CI.
In company may be many modules in separate repositories (I have over 100). This is exactly modules. They may be build one Jenkinsfile. But save duplicate Jenkins file each repository makes very hard support.
This is plugin have Jenkinsfile in global Jenkins script store. And load is for all tasks.
The Jenkinsfile may load specified Jenkinsfile from SCM for build concrete module branch.
Basics
This plugin extend workflow-multibranch-plugin and differs only one option in configuration
How it works
Config files load in order:
- Jenkinsfile from root in checkout
- Jenkinsfile from global Jenkins script store
- Jenkinsfile from UI - not realized
Configuration steps
Create job
Enter name and select job type:
Select build mode
In job options go to "Build Configuration" section and select "by default Jenkinsfile":
If your select option "by Jenkinsfile" task will also work as a Workflow Multibranch Plugin
Select other options
All other options fully equivalent with Workflow Multibranch Plugin
Create and save default Jenkinsfile
Write your default Jenkinsfile (Pipeline write tutorial) and go to "Managed files" in jenkins manage section:
Add new config file with Groovy type and Jenkinsfile name:
Write pipeline:
After change global scripts may require administrative approval
Usage sample
All modules builds default Jenkinsfile. This is libs and other dependencies. But have modules with specific build configurations (run hard tests, deploy to docker etc.) Default configurations sample:
#!groovy
node('builder-01||builder-02||builder-03') {
try {
stage('Checkout') {...}
stage('Prepare') {...}
def hasJenkinsfile = fileExists 'Jenkinsfile'
if (hasJenkinsfile) {
load 'Jenkinsfile' // Loading Jenkinsfile from checkout
} else {
stage('Build') {...}
stage('Test') {...}
}
currentBuild.result = 'SUCCESS'
} catch (error) {
currentBuild.result = 'FAILURE'
throw error
} finally {
stage('Clean') {...}
}
}
Jenkinsfile in SCM example:
#!groovy
stage('Build') {...}
stage('Deploy and Tests') {...}
currentBuild.result = 'SUCCESS'
Versions
1.0 (18.11.2016) - First release under per-plugin versioning scheme.
1.1 (05.01.2017) - Actual dependencies versions. Thanks @nichobbs #1
WARNING This version is now saved different then it used to and a rollback of this release is not supported. If you'r unsure, please save your configuration before updating.
Update plugins Config file provider, Workflow multibranch and their dependence.
Authors
- Saponenko Denis - Initial work - vaimr
See also the list of contributors who participated in this project.
License
The MIT License
Copyright (c) 2016 Saponenko Denis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.