Learning new tech skills and software takes time and consistency. This post covers the process I followed to learn and implement a new technology.
Task: Install Jenkins via Helm and build a pipeline that builds and pushes a Docker image from a Gitea repository.
Step 1: Planning
- Identify the steps and resources needed to deploy Jenkins
- Determine the app to deploy
- Determine the values needed for Helm
- Research how to connect Jenkins to Gitea
- Plan the Jenkins pipeline
- Determine if additional Jenkins tutorials or training are needed
- Plan for accessing Jenkins (VPN, Ingress, etc.)
Step 2: Code
- Learn about Jenkins through watching YouTube content and taking Jenkins KodeKloud course (affiliate link)
- Develop a backend API using Python Github link
- Reference Jenkins’ GitHub documentation to install Helm
- Connect Jenkins to Gitea using the Gitea Jenkins plugin and an access token
- Write the pipeline code in a
Jenkinsfile
using either a Declarative or Scripting syntax
Below is a screenshot of Jenkins deployed via ArgoCD.
Step 3: Build
With the prereqs completed it was time to:
- Validate that Jenkins can see the Gitea repository
- Build the backend API Docker image and push it to Docker Hub using the following pipeline code snippet:
# Jenkinsfile
podTemplate(
containers: [containerTemplate(name: 'docker', image: 'docker', command: 'sleep 1000')],
volumes: [hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')]){
node(POD_LABEL) {
def api
container('docker'){
stage('Clone-repo-build-docker-image') {
/* ensure repo is cloned */
checkout scm
/* This builds the actual image; synonymous to
* docker build on the command line */
dir("coffee_shop_api"){
api = docker.build("myDockerHub/coffee_shop_api")
}
}
stage('Testing'){
try {
sh 'pip install -r requirements.txt'
sh 'pytest'
}
catch (exc) {
echo 'Pytest tests failed'
}
}
stage('Post to DockerHub') {
docker.withRegistry('', 'dockerhub') {
api.push()
}
}
}
}
}
The following is the outcome of the successful Docker build, and the Docker image is now available for download from Dockerhub.
These steps took place over the course of a week, working on each task daily for 60-90 minutes and focusing on completing one task before moving on to the next.
Consistency and enjoyment are key to sustained learning and success.S
In the next post, I will further discuss the CI/CD process.