Pipeline job generation made easy
This Jenkins Library introduces :
- a new way to import jobs programmatically into jenkins. Basically it is a parser that converts Declarative Pipelines to JobDSL Declarative Pipelines This embed a template engine to generage multiple jobs from one Jenkinsfile template (or more) parametarized by property files
- a clever way to reduce drastically the numbers of calls made by github by your pipelines this library automates the process of storing and updating a shared library on jenkins filesystem
- Reduce the number of jobs to maintain
- develop pipelines without the need configure jobs on jenkins
- Handle multiple microservices and their jenkinsfile from one repo. Meta repository is handy when the project you work on has too many microservices and was not designed with deployment in mind.
From the Configure System administration page, add the library https://github.com/SAP/jenkins-pipelayer.git, name it
jenkins-pipelayer
for convenience
Have a look at USAGE.md for a detailed procedure of the import.
@Library('jenkins-pipelayer')_
The library adds the folowing steps to Jenkins pipeline dsl:
- generateJobs => Parse pipeline dsl, translate it to jobdsl and create a jenkins job
- approveScripts => this step approves jobs generated from templates on jenkins
- libToFs => particularly useful to reduce the number of queries to github
Have a look at USAGE.md for a description of the steps introduced by Jenkins Pipelayer.
The template engines introduced by step generateJobs
can create and manage jobs based on the same template parameterized by multiple property files.
For instance, the following two property files would generate job1 and job2, where job 1 displays example.com
and job2 displays site.com
// ./config/myjob1.properties
hcp.host=example.com
// ./config/myjob2.properties
hcp.host=site.com
// mytemplate.groovy
steps {
println "{{hcp.host}}"
}
see the usage documentation here for the template engine
We made samples to help you understand how to use the library. Please check out the sample folder
Install the requirements. Run lint and tests with command:
gradlew codenarcMain test
Have a look at our Contribution Guidelines, there is more info there.
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the LICENSE file.