Skip to content

pro-vision/jenkins-pv-pipeline-library

Repository files navigation

Build Code Coverage Maven Central Sonatype Snapshots

PV Pipeline Library

The PV pipeline library is an extension for the pipeline library and adds steps to standardize the maven build process in pro!vision projects.

💡 Is is absolutely recommended to read the wcm-io-devops Jenkins Pipeline Library documentation of the pipeline library.

Table of contents

Key concepts

The main concepts of the pv pipeline library are

  • DRY
  • Maintainability
  • Configurability

It reduces the code a developer has to write to get the project build by Jenkins. It consolidates the characteristics of our projects but also provides a high level of configurability.

Default maven build

The requirements of our maven based project have a large congruence. A normal maven project has the following steps:

  • Set job properties (like log rotation, no concurrent builds)
  • Checkout code from SCM using GIT
  • Remove existing project and dependency snapshots from local maven repository (e.g. from io.wcm)
  • Build the maven project and deploy the artifacts to nexus
  • Analyse the maven project (e.g. pmd, checkstyle, opentasks, findbugs)
  • Publish reports (e.g. JUnit, pmd, checkstyle, opentasks, spotbugs etc.)
  • Notify the teams when a job status changes (e.g. failure, unstable, fixed)

To avoid that each project has redundant pipeline code doing these steps this library introduces the buildDefault

Feature maven build

Building a feature branch is the same as the default maven build with two exceptions:

  • The branch is merged with master before build
  • The artifacts are not deployed to nexus (so no mvn clean deploy)

The buildFeature step automatically takes care of this.

routeDefaultJenkinsFile

The routeDefaultJenkinsFile the main part for DRY. This step automatically detects if the current pipeline build is a "normal" pipeline build or a multi branch pipeline build.

With this step it is possible to place one Jenkinsfile in you project root which looks like this:

@Library('pipeline-library') pipelineLibrary
@Library('pv-pipeline-library') pvPipelineLibrary

routeDefaultJenkinsFile()

Configurability

Even when the pv pipeline library streamlines the jenkins build it provides a large amount of configuration options to ensure that project specific needs are covered.

💡 Have a look at Configuration for more information.

💡 It is also recommended to read the config structure documentation from pipeline library.

Extensibility

You can extend the pipelines / steps by providing custom callbacks/closures at specific points.

💡 Have a look at Extension options for more information.

Provide default tools

The big part of our projects is using JDK and Apache Maven 3. So the initialization of these tools was moved to the step setupPVTools to make this easier.

Requirements

In order to use the pv pipeline library you have to fulfil these requirements:

Steps

The PV pipeline library provides the following steps:

Utilities

The PV pipeline library provides the following utilities:

Tutorials

located here: docs/tutorials.

The most important tutorials:

Documentation

General documentation is in the docs folder.

Please have a look at the Configuration documentation for config options and configuration examples.

Building/Testing

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 test/io.

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 test/vars.

Building with maven

mvn clean install

Add license file headers

mvn license:update-file-header