A2oz

How to Install Jenkins Plugins in Docker?

Published in Jenkins 2 mins read

You can install Jenkins plugins in Docker by using the following methods:

1. Using the Jenkins Dockerfile

  • Create a Dockerfile: Start by creating a Dockerfile that includes the base Jenkins image and the desired plugins.
  • Specify plugins: Use the JENKINS_PLUGINS environment variable to list the plugin names separated by commas.
  • Build and run the image: Build the Docker image using the Dockerfile and then run the container.

Example Dockerfile:

FROM jenkins/jenkins:lts

ENV JENKINS_PLUGINS="git,maven,pipeline"

# ... other configurations ...

2. Installing Plugins After Container Startup

  • Start the Jenkins container: Run the Jenkins container without specifying any plugins.
  • Access the Jenkins web interface: Once the container is running, access the Jenkins web interface using the exposed port.
  • Install plugins: Navigate to the "Manage Jenkins" section and then to "Manage Plugins." Search for the desired plugins and install them.

3. Using a Plugin Manager Tool

  • Use a plugin manager tool: Some tools like jenkins-plugin-cli can be used to install plugins remotely.
  • Install the tool: Install the plugin manager tool on your host machine.
  • Use the tool to install plugins: Run the tool with the appropriate commands to install the desired plugins on the Jenkins container.

Example using jenkins-plugin-cli:

jenkins-plugin-cli install git maven pipeline -s http://<jenkins_host>:<jenkins_port>

Note: Replace <jenkins_host> and <jenkins_port> with the actual host and port of your Jenkins container.

These methods allow you to install Jenkins plugins within a Docker environment, ensuring that your Jenkins setup includes the necessary functionality.

Related Articles