Customizing Jenkins
A Jenkins server is deployed during the initial setup process. The implementation provided is based on the following community tools:
It is an option to customize and redeploy Jenkins if you require changes to meet your needs.
Configuring Jenkins
The configuration for Jenkins is split into the following:
- The
bootstrap/jenkins-helm-values.yaml.tmpl
file. This provides the majority of the configuration for Jenkins and includes:- The admin credentials to access Jenkins.
- Resource settings (RAM/CPU) for the Jenkins server. Resource settings for the agents are defined in files in
jenkins/agents/kubernetes
. - The plugins to install.
- The configuration for the Jenkins plugin Kubernetes.
- The persistent volume settings.
- The Groovy based init script to run:
- Creates the Jenkins Credential for the git server, based on the values set in
docker-compose.yml
for the bootstrap process. - Adds the ssh host key to the server, also from the
docker-compose.yml
file. - Creates and starts the bootstrap job inside Jenkins, where the job itself is defined in
cloudops-for-kubernetes/jenkins/jobs/bootstrap/bootstrap.groovy
.
- Creates the Jenkins Credential for the git server, based on the values set in
- The files in the
cloudops-for-kubernetes/jenkins/jobs
directory which define the Jenkins jobs. - The files in the
cloudops-for-kubernetes/jenkins/docker
directory which provides the Docker images that are used for the Jenkins agents. - The
jenkins-secrets
Kubernetes secret. This is normally created by the bootstrap process and it provides many settings used by the Jenkins jobs.
Updating the Docker Images for the Jenkins Agents
Jenkins agents in CloudOps for Kubernetes use the Docker images in the jenkins/agents/docker
directory. If these Docker images need to be rebuilt, run the build-jenkins-agents
job.
Updating the Jenkins Jobs
To update the implementation of Jenkins jobs, push the code to the CloudOps for Kubernetes repository and branch set in the docker-compose.override.yml
file used during the bootstrap process.
If the configuration of the Jenkins job is changed by editing the jenkins/jobs/bootstrap/bootstrap.groovy
file, run the bootstrap
Jenkins job for the changes to be imported into the Jenkins server. The bootstrap
job updates any jobs where the configuration has changed.
If an Account Management job configuration has been updated by editing the jenkins/jobs/bootstrap-account-management/bootstrap.groovy
file, run the bootstrap-account-management
Jenkins job.
Updating Jenkins
By default, Jenkins is deployed during the initial setup process.
If you need to update Jenkins or its plugins, test the changes first, ideally in an environment where errors will not impact development or production operations. You can perform tests to validate that the newer plugins do not have breaking changes either for the bootstrap container or any of the Jenkins jobs.
Plugin Upgrade Testing Process
Deploy a new environment using the bootstrap container
Manually upgrade Jenkins and its plugins using the Jenkins web interface
Collect the names and versions of the Jenkins plugins
The easiest way to get the plugin names and versions is to run the following code in the Jenkins Script Console:
Jenkins.instance.pluginManager.plugins.each{ plugin -> println ("${plugin.getShortName()}: ${plugin.getVersion()}") }
Update the code to use the new version of Jenkins and the plugins
- The
bootstrap/jenkins-helm-values.yaml.tmpl
andjenkins.tf
files would have to be modified
- The
Deploy another new environment, using this newly updated code
Validate that all the Jenkins jobs in this new environment function as expected.
Update the Jenkins server version and plugins in the code of cloudops-for-kubernetes
Run the bootstrap container in "create" mode to apply the code changes
Remove the environments created for this task.