Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Installing Plugins via CLI in Jenkins

1. Introduction

Jenkins is a widely used open-source automation server that supports building, deploying, and automating projects. Plugins extend its functionality, making it essential to understand how to install them efficiently. This lesson covers the process of installing Jenkins plugins via the Command Line Interface (CLI).

2. Prerequisites

  • Jenkins server installed and running.
  • Java installed on the machine.
  • Access to the Jenkins CLI.
  • Basic knowledge of command line operations.

3. Step-by-Step Guide

3.1 Accessing Jenkins CLI

To install plugins via CLI, you first need to download the Jenkins CLI jar file.

wget http:///jnlpJars/jenkins-cli.jar

3.2 Installing a Plugin

Use the following command to install a plugin:

java -jar jenkins-cli.jar -s http:/// install-plugin 

For example, to install the Git plugin:

java -jar jenkins-cli.jar -s http:/// install-plugin git

3.3 Installing Multiple Plugins

To install multiple plugins at once, separate them with spaces:

java -jar jenkins-cli.jar -s http:/// install-plugin git workflow-aggregator

3.4 Restarting Jenkins

After installation, it is advisable to restart Jenkins for the changes to take effect:

java -jar jenkins-cli.jar -s http:/// safe-restart

4. Best Practices

Note: Always ensure that you are installing plugins that are compatible with your Jenkins version to avoid issues.
  • Regularly update plugins to their latest versions.
  • Backup Jenkins and its configurations before major changes.
  • Test plugins in a staging environment if possible.

5. FAQ

What if a plugin fails to install?

Check the plugin name for typos, ensure your Jenkins server is reachable, and consult the Jenkins logs for errors.

Can I install plugins without restarting Jenkins?

Yes, but some plugins may require a restart to activate. Use the --restart option for immediate restarts after installation.

How do I list installed plugins?

You can list installed plugins using the command:

java -jar jenkins-cli.jar -s http:/// list-plugins