Page tree
Skip to end of metadata
Go to start of metadata

Links:

Setup

Run a local Jenkins: docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts

Jenkins doesn't come with the necessary plugins OOTB, there's one that needs to be installed, look it up in MPL's README.

Once that's done, add both MPL (general framework) and the test-mpl-nested-library (for Magnolia specifics) as shared libraries.

Scenarios

Override a step

Build.groovy is overriden in the override branch of the test-mpl-project by using the following path: .jenkins/modules/Build/Build.groovy

Run Maven/JS projects with the same pipeline

The js branch of the test-mpl-project will run a Node build thanks to the logic in: https://github.com/magnolia-cms/test-mpl-nested-library/blob/master/resources/info/magnolia/jenkins/modules/Build/Build.groovy

The advantage when all builds run the same pipeline (rather than a couple of templates as we do it currently) is that:

  • setup steps (such as downloading the build scripts, mounting the AWS volume),
  • settings,
  • and even 'business logic' (JIRA health check, binary compatibility, etc.)

do not need to be copy-pasted, but can simply be turned on/off on demand.

Examples of customization (non-exhaustive list)

Disable steps from the project pipeline:

NestedPipeline {
  modules.BinaryCompatibility = null
}

Tweak steps thanks to MPL configuration (not my example):

@Library('mpl') _

// Use default master pipeline
MPLPipeline {
  // Pipeline configuration override here
  // Example: (check available options in the pipeline definition)
  agent_label = 'LS'                     // Set agent label
  modules.Build.tool_version = 'Maven 2' // Change tool for build stage
}

Tests

The framework comes with helper methods and examples that allow to easily write tests like the following: https://github.com/magnolia-cms/test-mpl-nested-library/blob/master/test/groovy/info/magnolia/jenkins/modules/Build/BuildTest.groovy

This is a big advantage over our current implementation where we have no visibility once we push changes.

  • No labels