Search⌘ K
AI Features

Jenkins Kata 6: Deploying Containers (Step 4–6)

Explore how to define deployment jobs in Jenkins for Dev, QA, and Production environments. Understand implementing manual approval steps within the deployment pipeline and adding pipeline views for visualizing CI/CD workflow connections. Gain practical skills in managing controlled and automated container deployments.

Step 4: Define a QA environment deployment job

The following are the steps to define a QA environment deployment job:

  • Return to the Jenkins tab.
  • Click the “Jenkins” icon at the top left.
  • Click “New Item.”
  • Enter “qa-deploy-storelist” in the item name field.
  • Select “Freestyle project.”
  • Click “OK.”
Job creation for qa-deploy-storelist
Job creation for qa-deploy-storelist
  • Click the “Build Steps” tab.
  • Select “Add build step.”
  • Select “Execute shell.”
  • Enter the following commands:
Shell
docker container rm -f qa-storelist || true
docker container run -d -p 8002:80 --net=storelist-net --ip=172.20.0.15 --name qa-storelist ed-6091404232622080.educative.run/dk/storelist
  • Click “Save”
Adding commands in the “Command” field
Adding commands in the “Command” field

Commands

Command / Parameter

Description

docker container

This is the Docker parent command for containers.

rm

This removes a container.

-f

This forces the removal of a container even if it's running. If the container is running, it's killed and then removed.

qa-storelist

This is the name of the container to remove.




|| true

The double-pipe character is a “logicial OR.”

If the `qa-storelist` container is not running, the Docker `rm` command will fail. This is expected; however, it would cause the command to return a failure code, causing the job to fail. The OR statement returns true from the command even if the docker `rm` command fails.

This ensures that this command will return a success code, whether the `qa-storelist` container was running or not.

docker container

This is the Docker parent command for containers.

run

This runs a new container.

-d

This runs a disconnected container.

-p

This maps ports from the host to the container.

8002:80

This maps port 8002 on the host to port 80 in the container.

--net=storelist-net

This assigns a user-defined Docker bridge network to the container.

--ip=172.20.0.15

This assigns a static IP to the container within the subnet range defined on the user-defined network.

--name

This assigns a name to the container.

qa-storelist

This is the name assigned to the container.

ed-6091404232622080.educative.run/dk/storelist

This is the URL to the private repository and the name of the image to run.

  • Click “Build Now.”
Click “Build Now”
Click “Build Now”
  • Click back to “Dashboard.”
  • Select the “dev-deploy-storelist” job.
  • Click “Configure.”
  • Click the “Post-build Actions” tab.
  • Select “Add post-build action.”
  • Select “Build other projects (manual step).”
  • Enter “qa-deploy-storelist” in the “Downstream Project Names” field.
  • Click
...