Cloud Native 10 min read

Build, Deploy, and Push Docker Images with KubeSphere DevOps Pipelines

This guide walks you through creating a KubeSphere DevOps project, configuring Jenkins pipelines, pulling code, compiling Java with Maven, building Docker images, tagging and pushing them to a registry, and deploying the application, complete with screenshots and step‑by‑step instructions.

Qingyun Technology Community
Qingyun Technology Community
Qingyun Technology Community
Build, Deploy, and Push Docker Images with KubeSphere DevOps Pipelines

Introduction

Based on Jenkins, the KubeSphere DevOps system is designed for CI/CD workflows in Kubernetes, offering an all‑in‑one solution for building, testing, and releasing applications, with features such as plugin management, Binary‑to‑Image, Source‑to‑Image, dependency caching, code quality analysis, and pipeline logs.

The system provides an automated environment where applications can be automatically published, supports third‑party private image registries (e.g., Harbor) and code repositories (GitLab/GitHub/SVN/BitBucket), and delivers a visual CI/CD pipeline useful even in offline environments.

In short, DevOps can automate code checkout, project compilation, image building, image pushing, and deployment in a single workflow.

Create DevOps Project & Pipeline

To create a DevOps project: Workspace → DevOps Project → Create, enter a project name and confirm.

To create a pipeline: open the newly created DevOps project, go to the Pipeline menu, click Create, and enter a pipeline name.

The code repository field is optional; if filled, a webhook address is generated to trigger the pipeline on code commits.

In this demonstration we skip the repository, enter the pipeline name, and click Next → Create.

Edit Pipeline

Open the created pipeline and click Edit Pipeline.

Select the second template and save.

In the pipeline editor, the agent section shows type and label. Choose “node” as the agent type and select a label according to the project language: maven for Java, nodejs for frontend, go for Go, or base for others.

1. Pull Code

Step 1: Click to open the right‑hand window.

Step 2: Enter the stage name.

Step 3: Delete the default base container because we will use a Maven container.

Add a step, choose a specific container, and set its name.

Add a nested step to pull code via Git (or SVN). Fill in the repository URL, branch, and create credentials.

Credential ID: any name.

Type: Username with password.

Username: Git username.

Password/Token: Git password.

Optionally add a nested step to display the checked‑out code directory.

Run the pipeline to verify the pull step.

2. Build Project

Edit the pipeline, add a stage named “Project Build”, select the Maven container, add a nested shell step, and run the Maven package command.

$ mvn clean package -Dmaven.test.skip=true

Save and run to confirm successful compilation.

3. Build Image

Add a stage “Build Image” with agent type “none”. Use a Maven container to list the built artifact and then run Docker build.

ls isee-gateway/target
$ docker build -t isee-gateway:latest -f isee-gateway/Dockerfile isee-gateway/
Parameters: isee-gateway:latest is the image name and tag; -f specifies the Dockerfile; isee-gateway/ is the build context directory.

Parallel steps can be added to build multiple micro‑service images.

4. Push Image

Add a stage “Push Image” (e.g., to Alibaba Cloud registry) with agent type “none”. Create credentials, then use shell steps to log in, tag, and push the image.

Login step:

$ echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin

Tag step:

$ docker tag isee-gateway:latest $REGISTRY/$DOCKERHUB_NAMESPACE/isee-gateway:SNAPSHOT-$BUILD_NUMBER

Push step:

$ docker push $REGISTRY/$DOCKERHUB_NAMESPACE/isee-gateway:SNAPSHOT-$BUILD_NUMBER

Parallel steps can push multiple images.

5. Deploy

After saving the pipeline, edit the Jenkinsfile to set the REGISTRY variable to your own registry address and configure the KUBECONFIG_CREDENTIAL_ID (default demo‑kubeconfig). Create the required credentials, save, and run the pipeline to complete deployment.

Running the pipeline now executes the full CI/CD process from code checkout to deployment.

DockerCI/CDKubernetesmavenJenkinsKubeSphere
Qingyun Technology Community
Written by

Qingyun Technology Community

Official account of the Qingyun Technology Community, focusing on tech innovation, supporting developers, and sharing knowledge. Born to Learn and Share!

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.