Skip to content

Jenkins

Cloudbees Study Guide

Tuning

Please read the following articles from Cloudbees:

Pipeline as code

The default interaction model with Jenkins, historically, has been very web UI driven, requiring users to manually create jobs, then manually fill in the details through a web browser. This requires additional effort to create and manage jobs to test and build multiple projects, it also keeps the configuration of a job to build/test/deploy separate from the actual code being built/tested/deployed. This prevents users from applying their existing CI/CD best practices to the job configurations themselves.

With the introduction of the Pipeline plugin, users now can implement a project’s entire build/test/deploy pipeline in a Jenkinsfile and store that alongside their code, treating their pipeline as another piece of code checked into source control.

We will dive into several things that come into play when writing Jenkins pipelines.

  • Kind of Pipeline jobs
  • Info about Pipeline DSL (a groovy DSL)
  • Reuse pipeline DSL scripts
  • Things to keep in mind
  • Do's and Don't

Resources

Type of pipeline jobs

Danger

When using the stash function keep in mind that the copying goes from where you are now to the master. When you unstash, it will copy the files from the master to where you are building.

When your pipeline runs on a node and you stash and then unstash, it will copy the files from the node to the master and then back to the node. This can have a severe penalty on the performance of your pipeline when you are copying over a network.

API

Jenkins has an extensive API allowing you to retrieve a lot of information from the server.

Plugin

For this way you of course have to know how to write a plugin. There are some usefull resources to get started: * https://github.com/joostvdg/hello-world-jenkins-pipeline-plugin * https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial * https://jenkins.io/blog/2016/05/25/update-plugin-for-pipeline/

Do's and Don't

Aside from the Do's and Don'ts from Cloudbees, there are some we want to share.

This changes the requirement for the component identifier property, as a job may only match a single group and a job listing in a group can only match a single. Thus the easiest way to make sure everything will stay unique (template names probably don’t), is to make the component identifier property unique per file - let it use the name of the project.

Other Resources


Last update: 2019-08-31 13:12:00