Skip to main content
In Kubernetes, all containers in the same Pod share the same filesystem volume. This demo shows how one Jenkins pipeline stage writes a file in an Ubuntu container, and a subsequent stage reads it in a Node.js container—both running side by side in the same Pod.
  • A Jenkins server with the [Kubernetes Plugin][] and [Blue Ocean][] installed.
  • A connected Kubernetes cluster configured as a cloud agent.

Jenkinsfile Overview

The following Jenkinsfile defines two stages: one running on Ubuntu, the other in a Node.js sidecar. They share the workspace via an emptyDir volume.

Executing the Pipeline

When this pipeline runs, Jenkins dynamically provisions a Pod with two containers—ubuntu-container (default) and node-container (sidecar)—sharing an emptyDir workspace volume.
The image shows a Jenkins dashboard displaying the status of a pipeline named "k8s-cloud-agent-demo," with several stages and their execution results. The interface includes options like "Delete Pipeline" and "Open Blue Ocean" on the left sidebar.
Under the hood, the Pod specification looks like this:
The image is a screenshot from the Kubernetes documentation website, showing a diagram of a multi-container Pod with a file puller sidecar, a web server, and a shared volume.

Pipeline Log Example

The log below confirms the file created in the Ubuntu container is accessible in the Node.js container:

Static Nodes vs. Dynamic Agents

You can run Jenkins jobs on:
Dynamic agents help you package toolchains into container images, cutting down on idle resources and improving build scalability.

Further Reading

Watch Video