Jenkins Pipeline Library
Since Jenkins Pipeline has reached a certain state of production scripted pipelines are the way to go.
But: Not everything known from the UI is available in Pipeline and configuring and writing scripts is not so easy for the normal developer.
The target of this library is to take out some complexity (and yes
adding some too) of the pipeline creation and to bring back some known
functionality (for example
variables, mail notification on still unstable etc.)
Want to see an example? Have look at Usage examples
Table of contents
- Key concepts
- Credential and managed file auto lookup
- Support for command line execution
- Setup your environment to use the pipeline library
- Changes / Version History
The pipeline library was developed with a focus to ease Java and Maven build processes within companies which have a more or less similiar project structure e.g.
- local Artifact Server (like Sonatype Nexus or Artifactory)
The assumption is that in these environments
- Jenkins has a dedicated user account to checkout code (or one per project)
- the artifact server caches public artifacts and acts as a internal artifact server
So the key concepts of the pipeline enable you to
- Auto provide credentials (no worries, only Jenkins credential ids, not the credential itself) (see Credentials)
- Auto provide maven settings (see ManagedFiles)
- configure each job the same way (see ConfigStructure)
- log and see the things you are interested in (see Logging)
Running this pipeline library will result in more structured and easier to maintain pipeline scripts.
Configured properly this library enables you to checkout scm with these lines of code:
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.* checkoutScm( (SCM) : [ (SCM_URL) : "firstname.lastname@example.org/group/project.git", ] )
Or running maven with local and global maven settings with these lines of code:
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.* execMaven( (SCM) : [ (SCM_URL) : "email@example.com/group/project.git", ], (MAVEN): [ (MAVEN_GOALS) : [ "clean", "install" ] ] )
Have a look at requirements to get the library running.
The pipeline library comes with the following steps:
- im (instant messaging)
- Build Parameter Factory
- Integration Testing
- Configuration map merging
Credential and managed file auto lookup
- Generic Configuration
Support for command line execution
Setup your environment to use the pipeline library
Please refer to SetupTutorial for detailed instruction on how to setup the library in your environment.
The library uses two approaches for testing.
The class parts are tested by unit testing using JUnit/Surefire. All
unit tests have the naming format
*Test.groovy and are located below
The step parts are tested by using
Jenkins Pipeline Unit
with jUnit/Failsafe. All integration tests have the naming format
*IT.groovy and are located below
Building with maven
mvn clean install
Add license file headers
Changes / Version History
Please have a look at the Releases