Member-only story

Jenkins Configuration As Code

Maciej
3 min readMay 14, 2021

--

What Exactly is JCasC ?

This is a plugin that encodes all Jenkins settings and allows us to manage Jenkins settings without clicking on the GUI. This is quite advantageous when we have a fairly extensive configuration of our Jenkins, and it is especially useful in the case of a restore.

Environment

Let’s Start

Run sample full environment which can be found at this link

C:\Temp
λ git clone https://github.com/spy86/jenkins-as-code-docker-demo.git
C:\Temp
λ cd jenkins-as-code-docker-demo\
C:\Temp\jenkins-as-code-docker-demo (master -> origin)
λ vagrant up

After a while, the ready environment should start with Jenkins, and we can login into Jenkins. Open URL http://192.168.123.123:8089/ you should see one job SeedJob on the dashboard, and access for all options.

Jenkins configuration explanation

The configuration of Jenkins based on the jcasc plugin is divided into individual sections that are responsible for the configuration of individual functionalities in Jenkins. Below there are few important sections:

  • jenkins: The main element of the configuration in which we configure most of the options

Example code:

jenkins:
systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n"
globalNodeProperties:
- envVars:
env:
- key: VARIABLE1
value: example1
- key: VARIABLE2
value: example2
numExecutors: 1
crumbIssuer:
standard:
excludeClientIPFromCrumb: false
remotingSecurity:
enabled…

--

--

Maciej
Maciej

Written by Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.

No responses yet

Write a response