Jenkins Kata 6: Deploying Containers (Step 4–6)
Learn about adding a build pipeline, defining and configuring a Dev, QA, and production environment deployment job, and adding a pipeline view.
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.”
- Click the “Build Steps” tab.
- Select “Add build step.”
- Select “Execute shell.”
- Enter the following commands:
docker container rm -f qa-storelist || truedocker 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”
Commands
Command / Parameter | Description |
| This is the Docker parent command for containers. |
| This removes a container. |
| This forces the removal of a container even if it's running. If the container is running, it's killed and then removed. |
| This is the name of the container to remove. |
| 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. |
| This is the Docker parent command for containers. |
| This runs a new container. |
| This runs a disconnected container. |
| This maps ports from the host to the container. |
| This maps port 8002 on the host to port 80 in the container. |
| This assigns a user-defined Docker bridge network to the container. |
| This assigns a static IP to the container within the subnet range defined on the user-defined network. |
| This assigns a name to the container. |
| This is the name assigned to the container. |
| This is the URL to the private repository and the name of the image to run. |
- 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