Operations 12 min read

Implementing Continuous Integration with Jenkins and Docker

This article explains how to set up a Jenkins-based CI/CD pipeline using Docker, covering Jenkins concepts, deployment via Docker containers, master‑slave configuration, essential Docker plugins, and API usage with practical command‑line examples for building automated workflows.

360 Tech Engineering
360 Tech Engineering
360 Tech Engineering
Implementing Continuous Integration with Jenkins and Docker

The article, authored by the 360 Operations Development team, introduces a practical CI/CD workflow that combines Jenkins with Docker, aiming to inspire readers to adopt continuous integration for faster error detection and higher code quality.

Continuous Integration (CI/CD) is described as a software development practice that enables frequent integration and testing to catch integration errors early, improving code quality and reducing fault‑handling costs.

Common CI tools are listed, including Jenkins, ThoughtWorks GO, Bamboo, GitLab CI, Travis CI, and Buildbot, with Jenkins selected for the demonstration.

Jenkins Overview

Open‑source, widely used CI tool supporting CI and CD.

Highly extensible via a large ecosystem of plugins.

Excellent Docker support through dedicated plugins.

Pipeline support since Jenkins 2.0 using Groovy‑based DSL.

Developed in Java.

Key Jenkins Concepts master: the Jenkins server that parses job scripts and schedules resources. agent: executes tasks dispatched by the master. executor: the compute resource on which jobs run (on master or agents). job: defines a specific build process.

Groovy: a JVM‑based language used as Jenkins’ DSL for pipelines.

Pipeline components: node, stage, and step. Jenkinsfile: a Groovy‑based script that describes the pipeline, analogous to a Dockerfile.

Jenkins Deployment with Docker

To deploy Jenkins, the official Docker image is used: docker search jenkins Pull the image: docker pull jenkins Run the container with a persistent data directory:

sudo mkdir /var/jenkins
sudo chown 1000:1000 /var/jenkins
sudo docker run -p 8080:8080 -p 50000:50000 -v /var/jenkins:/var/jenkins_home --name my_jenkins -d jenkins

After the container starts, Jenkins can be accessed via http://<host_ip>:8080. The local directory /var/jenkins holds all Jenkins data and should be owned by UID 1000.

Slave (Agent) Node Setup

Install Java JDK on the slave: yum install java-1.8.0-openjdk Create a Jenkins user:

useradd -m jenkins -d /home/jenkins
passwd jenkins

Create a workspace directory and set permissions:

mkdir /data/jenkins
chown jenkins.jenkins /data/jenkins

Add the Jenkins user to the Docker group: sudo usermod -a -G docker jenkins Configure password‑less SSH from master to slave:

ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub jenkins@slave_ip:~/.ssh/authorized_keys
chmod 700 authorized_keys

Docker Plugins for Jenkins

Several Docker‑related plugins are highlighted, such as Docker Commons Plugin, Docker Pipeline Plugin, Docker Hub Notification Trigger Plugin, CloudBees Docker Build and Publish, CloudBees Docker Custom Build Environment, CloudBees Docker Traceability, and the Kubernetes plugin for dynamic agent provisioning.

Jenkins Remote API

Jenkins provides a RESTful Remote API. For example, to create a new job named my_job:

<?xml version='1.0' encoding='UTF-8'?>
<project>
  <actions/>
  <description/>
  <keepDependencies>false</keepDependencies>
  <properties/>
  <scm class="hudson.scm.NullSCM"/>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <triggers class="vector"/>
  <concurrentBuild>false</concurrentBuild>
  <builders/>
  <publishers/>
  <buildWrappers/>
</project>

Upload the configuration via curl:

curl -X POST http://www.xxx.xxx/jenkins/createItem?name=my_job \
  --user uname:pass \
  --data-binary "my_job_config.xml" -H "Content-Type: application/xml"

After creation, the job can be accessed at http://myjenkins.com:8080/job/my_job and its API at /my_job/api/. Further API details are available in Jenkins’ official wiki.

Conclusion

The article provides a foundational guide to integrating Jenkins with Docker for continuous integration, with future topics planned on performance testing, scaling, and high availability.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Dockerci/cdAutomationPipelineJenkinsDocker Plugins
360 Tech Engineering
Written by

360 Tech Engineering

Official tech channel of 360, building the most professional technology aggregation platform for the brand.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.