Sign inSign up

mandarnilange/jenkins-controller

By mandarnilange

•Updated over 3 years ago

Controller for Jenkins example

Image
0

84

mandarnilange/jenkins-controller repository overview

This image to be used along with mandarnilange/jenkins-inbound-agent⁠

Please check Git repo - Jenkins as Code for this example⁠ for this image and instructions

⁠Jenkins as a Code (JCasC) Example

This example implements Jenkins as a code using Jenkins Configuration as Code Plugin⁠.

⁠Prerequisite

  • Docker
  • Linux / Mac machine with bash
  • Understanding of configuring Jenkins controllers and agents

Objective of this demo is to demonstrate capability to run Jenkins controller and agent as docker image (instead running them on VM).

⁠Features

This example uses official Jenkins docker images jenkins/jenkins⁠ and jenkins/inbound-agent⁠ as base images.

Implemented features

  • Script to create Jenkins controller docker image
  • configuration of Jenkins through jenkins.yaml
    • Two users setup admin and readonly (password same as username)
    • Access control for users
    • Two jobs setup for running through JOB DSL Plugin⁠
    • Permanent node setup docker-agent2
    • Two views for UI and Microservices
    • Global credential setup for git using ssh
  • Installation of required plugins (plugins.txt)
  • Script to create Jenkins Agent docker image
  • Shell scripts to build run controller and agent on linux/mac

⁠Quick Start - Run Jenkins

Start the Jenkins controller

docker run -p  8080:8080 -p 50000:50000 -e CASC_JENKINS_CONFIG=/usr/share/jenkins/ -e MY_JENKINS_URL="http://host.docker.internal:8080/"  mandarnilange/jenkins-controller

Go to Jenkins web controller at http://localhost:8080, and identify secret for docker-agent2.

Start Jenkins Agent

docker run --init -e JENKINS_URL=http://host.docker.internal:8080 -e JENKINS_AGENT_NAME=docker-agent2 -e JENKINS_AGENT_WORKDIR=/home/jenkins/agent -e JENKINS_SECRET=<Secret from master> mandarnilange/jenkins-inbound-agent

Go to Jenkins controller web and confirm agent is connected and jobs created to confirm job installation.

In case, you want to build yourself from source and run locally then check out Git repo - Jenkins as Code for this example⁠

⁠Next Steps

You can extend this implementation - some key next steps that can be taken

  • Add more users: update jenkins.yaml and recreate image
  • Setup more jobs: update jenkins.yaml and recreate image
  • Setup external volume for persistent storage: update startController.sh
  • Access private git repository: setup SSH_PRIVATE_KEY before starting controller
  • Install additional plugins: udpate plugins.txt and recreate image
  • Add more agents: update jenkins.yaml and recreate image

Happy Learning!

⁠References

mandarnilange/jenkins-controller⁠

mandarnilange/jenkins-inbound-agent⁠

Jenkins Configuration as Code Plugin⁠

DSL plugin docmentation⁠

Git repo - Jenkins as Code for this example⁠

Tag summary

Content type

Image

Digest

sha256:9a75f5a9d…

Size

399.8 MB

Last updated

over 3 years ago

docker pull mandarnilange/jenkins-controller