Run the fully automated installation of Jenkins from code with infrastructure, configuration, jobs, and plugins.
This is the implementation of "Everything as a Code" paradigm. The desired state is to be able to build a Jenkins instance where all of its infrastructure, plugins, credentials, jobs, and many other things are versioned and stored in Git.
This setup was built to support development on a Mac OS environment.
Export necessary variables:
export VAULT_APPROLE='role_id'
export VAULT_APPROLE_SECRET='secret_id'
git clone https://github.com/Kostua/Jenkins.git
cd Jenkins/
docker-compose up -d
There are five files that will be used in this example:
- Dockerfile - the definition of the Docker image
- docker-compose.yml - a file that helps us get all the Docker stuff up and running
- plugins.txt - the plugins that will be pre-installed in Jenkins
- jenkins.yaml - the definition of Jenkins with predefined job repository
Dockerfile - the definition of the Docker image It defines which version of Jenkins that be used and it pre-installs some plugins and additional packages.
docker-compose.yml - This creates a docker image from the Docker file and run Jenkins with network infra and connect all pice together.
plugins.txt - It contains a list of plugins and versions that should be installed before Jenkins is started.
jenkins.yaml - this is the place where Jenkins Configuration as Code (a.k.a. JCasC) Plugin comes into play. It lets us define the global and plugin configurations through a YAML file. Itβs great because it handles the configuration changes and we can deploy an initial Jenkins install with all the configurations already applied.
And this part is full predefined jobs from a repository and run all of them:
jobs:
- script: >
freeStyleJob('JobsGenerator') {
triggers {
hudsonStartupTrigger {
quietPeriod("60")
runOnChoice("ON_CONNECT")
label("")
nodeParameterName("")
}
}
scm {
github('Kostua/jenkins_as_code_jobs', 'master')
}
steps {
dsl {
external('*.groovy')
}
}
}
- script: >
queue('JobsGenerator')
Project is: in progress
Created by @kostua- feel free to contact me!