• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Managing Jenkins plugins from command line and GUI

December 2, 2018 by Sharad Chhetri

Jenkins Plugins play very important role for adding and enhancing the features in Jenkins. Managing Jenkins Plugin is also crucial. In simple term, manage Jenkins plugin carefully and in return you will get awesome functions and features.

In this post, we will learn managing Jenkins plugin from command line and GUI. Because Jenkins is automation server, we tried to bring more command line methods for automation folks.

In this post,we will refer the following variables. You have to replace with its correct value wherever we use in this post.

Variable Value
$JENKINS_URL The URL of your Jenkins Server.
Example: http://192.168.1.1:8080 or https://jenkins.example.com
$JENKINS_HOME Absolute path of Jenkins installed directory.
Example: /var/lib/jenkins or any custom path you have made.
$JENKINS_ADMIN_USER Jenkins user name which has admin privileges.
$JENKINS_ADMIN_PASSWD Password of $JENKIN_ADMIN_USERNAME.
$JENKINS_PLUGIN_URL Jenkins plugin download URL.
$JENKINS_PLUGIN_NAME Jenkins plugin short name.

Manage Jenkins Plugin

In GUI (Graphical User Interface), managing Jenkins plugin is quite easy. We will also add the cli(command line) which will help you in automation.

GUI Users

The GUI users can reach to plugin page by either directly open the URL $JENKINS_URL/pluginManager/ Or stepwise do click as shown in given below screenshot (“Manage Jenkins >> Manage Plugins“).

manage jenkins plugin

manage jenkins plugin

Command Line Users

Command line folks, download the jenkins-cli.jar file from your Jenkins Server.
Syntax:
wget $JENKINS_URL/jnlpJars/jenkins-cli.jar

##Example
wget http://localhost:8080/jnlpJars/jenkins-cli.jar

List Installed Jenkins Plugin – GUI / CLI

Here, we will list the installed Jenkins Plugin from GUI and CLI both.

List Installed Jenkins Plugin From Graphical User Interface (GUI)

In “Manage Plugin” page, click on “Installed” tab. This will show the list of Jenkins Plugin which are installed.
In web browser, quick URL path syntax is $JENKINS_URL/pluginManager/Installed.

List of installed Jenkins Plugin

List Installed Jenkins Plugin From Command Line Interface (CLI)

Syntax:
java -jar ./jenkins-cli.jar -s "$JENKINS_URL" -auth $JENKINS_ADMIN_USER:$JENKINS_ADMIN_PASSWD -noKeyAuth list-plugins

# Example
java -jar ./jenkins-cli.jar -s "http://localhost:8080" -auth admin:admin123 -noKeyAuth list-plugins

List Available Jenkins Plugin For Downloading – GUI / CLI

The ‘Available’ Jenkins plugin meaning is the plugins which are available for downloading and install.

List Available Jenkins Plugin For Downloading From Graphical User Interface (GUI)

In Jenkins ‘Manage Plugin’ page, click on “Available” tab. It will list all the available plugins which you can also install from same tab itself. The given below screenshot is self explanatory itself. Same we are discussing in our next Jenkins plugin installation section.

jenkins plugin

List Available Jenkins Plugin For Downloading From Command Line Interface (CLI)

You can curl and parse the result.
curl http://updates.jenkins-ci.org/download/plugins/

Install Jenkins Plugin – GUI / CLI

In this section we will learn installing the Jenkins Plugin.

Install Jenkins Plugin From Graphical User Interface (GUI)

Through GUI you can install Jenkins by 2 methods.

Method 1. Install Jenkins Plugin from ‘Available’ Tab | GUI

Given below is the order to follow.

  • Click on ‘Available’ tab
  • Select plugin by clicking checkbox
  • As per requirement either click “Install without restart” or “Download now and install after restart”

jenkins plugin

Method 2. Install Jenkins Plugin manually from ‘Advanced’ Tab | GUI

For this you have to download the package in system and then upload from web console. You can search the plugin from https://plugins.jenkins.io/ .

  • Click on ‘Advanced’ tab
  • Click on ‘Advanced…’ button (It will expand more options)
  • Go to ‘Upload Plugin’ Section >> Choose File >> Upload
  • click ‘Submit’ button at the end

Check given below screenshot for uploading plugin from web console.
install jenkins plugin

install jenkins plugin upload

Install Jenkins Plugin From Command Line Interface (CLI)

You can choose any one one option to install Jenkins plugin through command line.
Note: Here, -restart will restart the Jenkins service after successful installation of the plugin.

Syntax 1: You should have Jenkins Plugin Download URL. Search the Jenkins plugin from official website and get your plugin URL.
java -jar jenkins-cli.jar -s "$JENKINS_URL" -auth admin:admin123 -noKeyAuth install-plugin $JENKINS_PLUGIN_URL -restart

#Example 1: installing Jenkins plugin called git-parameter
java -jar ./jenkins-cli.jar -s "http://localhost:8080" -auth JENKINS_ADMIN_USER:JENKINS_ADMIN_PASSWD -noKeyAuth install-plugin https://plugins.jenkins.io/git-parameter -restart 

Syntax 2: You should have Jenkins Plugin short name.
java -jar jenkins-cli.jar -s "$JENKINS_URL" -auth admin:admin123 -noKeyAuth install-plugin $JENKINS_PLUGIN_NAME -restart

#Example 2 :Installing Jenkins plugin called git-parameter
java -jar ./jenkins-cli.jar -s "http://localhost:8080" -auth admin:admin123 -noKeyAuth install-plugin git-parameter –restart

Uninstall Jenkins Plugin – GUI / CLI

You can easily uninstall the Jenkins Plugin from GUI and CLI both. Currently to uninstall/remove Jenkins from CLI you have login into Jenkins Server and remove the plugin from its installation directory. We have described about the steps in given below sections.

Uninstall Jenkins Plugin From Graphical User Interface (GUI)

Go to Jenkins Manage Plugin page and follow the given below steps to uninstall Jenkins Plugin.

  • Click on’Installed’ tab,then
  • Select Jenkins Plugin to uninstall, then
  • Click ‘Uninstall’ button, then
    jenkins plugin uninstall
  • Click “Yes” button, then
    uninstall jenkins plugin
  • Restart Jenkins service. for restart you can append ‘restart’ string in JENKINS_URL. Click ‘Yes’ button for confirming the restart.
    Syntax: $JENKINS_URL/restart

    Jekins plugin uninstall

  • You will be logout after Jenkins restart.
  • Note: After uninstalling the plugin, to take effect you have to restart the Jenkins service.

Uninstall Jenkins Plugin From Command Line Interface (CLI)

To uninstall Jenkins plugin, login to Jenkins server. Change directory to Jenkins plugin path and remove the Jenkins Plugin jpi extension file and its related folder. This step you have to do after login in Jenkins Server terminal console.

Syntax:
cd $JENKINS_HOME/plugins
rm -fr Plugin-Name-DIRECTORY
rm Plugin-Name.jpi

See the given below screenshot carefully for clear understanding. Here, we are uninstalling the Jenkins plugin called ‘git-parameter’.
uninstall Jenkins plugin

Restart the Jenkins service after uninstalling the plugin. This step is mandatory.

sudo systemctl restart jenkins

Update Jenkins Plugin – GUI / CLI

It is very important to update Jenkins plugin on regular basis.It is important for security reason and bug fixes done in Jenkins Plugin.

Update Jenkins Plugin From Graphical User Interface (GUI)

In Jenkins Plugin Manager follow the given below steps in a sequence.

  1. Click on ‘Update’ tab.
  2. Select Check-boxes of Jenkins Plugin which you want to update
  3. Click on “Download now and install after restart”.
    update jenkins plygin
  4. Note: You may have noticed a button labelled as “Check Now”. This is for checking any Jenkins Plugin update is available.

Update Jenkins Plugin From Command Line Interface (CLI)

Updating Jenkins plugin through is 3 steps process (List and install the plugins then restart the Jenkins).

  1. First List the new plugins updates available to update
    Syntax: java -jar ./jenkins-cli.jar -s "$JENKINS_URL" -auth JENKINS_ADMIN_USER:JENKINS_ADMIN_PASSWD -noKeyAuth list-plugins| grep -e ')$'

    # Example
    java -jar ./jenkins-cli.jar -s "http://localhost:8080" -auth admin:admin123 -noKeyAuth list-plugins|  grep -e ')$' 
    
  2. Now you got the list from above command. Install these plugin from command line.
    java -jar jenkins-cli.jar -s "$JENKINS_URL" -auth JENKINS_ADMIN_USER:JENKINS_ADMIN_PASSWD -noKeyAuth install-plugin $JENKINS_PLUGIN_NAME

    # Example
    java -jar jenkins-cli.jar -s "http://localhost:8080" -auth admin:admin123 -noKeyAuth install-plugin workflow-support
    
  3. Do restart the Jenkins once plugins are installed.

    Syntax:java -jar enkins-cli.jar -s "$JENKINS_URL" -auth JENKINS_ADMIN_USER:JENKINS_ADMIN_PASSWD -noKeyAuth safe-restart;

    java -jar enkins-cli.jar  -s "http://localhost:8080" -auth admin:admin123 -noKeyAuth safe-restart;
    
  4. Bash Script To Update All Jenkins Plugin

    In above section we have already written about all the basic command line steps to update Jenkins plugin. In case you have many Jenkins Plugin to update then you should install it by using script. Here, we will write bash scripting using loop.

    Replace the values given in bash script variables.

    #!/bin/bash
    # Author: Sharad Chhetri
    # Description: Update all Jenkins plugin
    # Version 1.0
    
    _JENKINS_URL=http://localhost:8080
    _JENKINS_USER=admin
    _JENKINS_PASSWD=admin123
    
    java -jar ./jenkins-cli.jar -s "$_JENKINS_URL" -auth "$_JENKINS_USER:_JENKINS_PASSWD" -noKeyAuth list-plugins|  grep -e ')$' | awk '{ print $1 }'| while read _UPDATE_LIST;
    do 
    java -jar jenkins-cli.jar -s "$_JENKINS_URL" -auth "$_JENKINS_USER:_JENKINS_PASSWD" -noKeyAuth install-plugin "$_UPDATE_LIST";
    done
    
    java -jar jenkins-cli.jar -s "$_JENKINS_URL" -auth "$_JENKINS_USER:_JENKINS_PASSWD" -noKeyAuth safe-restart;
    

We hope the Jenkins Plugin Management will be helpful for you. You can use command line for your automation script.
Please do let us know your any kind of feedback to improve this post.

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to create Jenkins user by command line and GUI
  2. How to manage Jenkins Credentials
  3. How to setup Jenkins Credentials for Git repo access
  4. Install and setup maven in Linux for Jenkins
  5. How to install Jenkins on Ubuntu 18.04 LTS server
  6. plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory
  7. How to zip the directory in linux with command line
  8. How to upgrade ubuntu 12.10 to 13.04 through command line
  9. Convert new line to space by using sed command
  10. How to show line numbers with less command in Linux

Filed Under: Linux, Devops, Jenkins Tagged With: automation, devops, jenkins

Reader Interactions

Comments

  1. Praveen says

    May 19, 2021 at 11:31 am

    When I tried to do an update I see an error saying “ERROR:Failed to install plugin mailer”

    java -jar jenkins-cli.jar -s URL -auth id:password install-plugin mailer
    Installing mailer from update center

    ERROR: Failed to install plugin mailer

    Please suggest what could be the issue and where can I find the relevant logs.

  2. sunil says

    February 4, 2021 at 6:21 pm

    Hi sharad Chhetri ,

    am unable to install all plugins its installing only one plugin from the list .

    file = $1

    while read -r line; do
    java -jar jenkins-cli.jar -s “$_JENKINS_URL” -auth “$_JENKINS_USER:$_JENKINS_PASSWD” install-plugin “$line”;
    sleep 5
    done < plugins.txt

    java -jar jenkins-cli.jar -s "$_JENKINS_URL" -auth "$_JENKINS_USER:$_JENKINS_PASSWD" safe-restart;

  3. Michael says

    October 17, 2019 at 9:22 pm

    Hi,

    thanks for the detailed description and the script!

    However, we need to update our own custom plugin, i.e. it is not part of the UpdateCenter. I tried many different way, but non of them worked for me:
    – it cannot be referenced via the short name as it is not part of the Update Center
    – I didnt find a way to use cli command “install-plugin” to install a local with file:// – it always fails with FileNotFoundException (even though the path seems correct)
    – I cannot remove the existing folder of that plugin in JENKINS_HOME\plugins: fails with Access denied (I assume b/c Jenkins process is still using it)

    Any idea how to achieve that?

    Thanks a lot!
    Michael

  4. Eric Dunn says

    May 10, 2019 at 1:58 pm

    Hi (running on MacOS)

    Works until it hits “| while read _UPDATE_LIST;”

    See error.

    java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost:8080/cli?remoting=false
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1913)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
    at hudson.cli.FullDuplexHttpStream.(FullDuplexHttpStream.java:101)
    at hudson.cli.CLI.plainHttpConnection(CLI.java:668)
    at hudson.cli.CLI._main(CLI.java:628)
    at hudson.cli.CLI.main(CLI.java:427)

    • Sharad Chhetri says

      May 26, 2019 at 3:21 pm

      Hi Eric,

      Which Jenkins version are you using. I suspect it could be old version because Jenkins 2.165 and newer no longer supports the old (-remoting) mode in either the client or server.

      (reference: https://jenkins.io/doc/book/managing/cli/#authentication)

      Regards
      Sharad

      • Rajasekhar says

        November 27, 2019 at 7:42 am

        “$_JENKINS_USER:$_JENKINS_PASSWD”

        Add $ to the _JENKINS_PASSWD variable.

    • Rajasekhar says

      November 27, 2019 at 7:31 am

      Corrected the script by appending $ to the _JENKINS_PASSWD variable :

      #!/bin/bash
      # Author: Sharad Chhetri
      # Description: Update all Jenkins plugin
      # Version 1.0

      _JENKINS_URL=http://164.99.177.111:8080/jenkins
      _JENKINS_USER=admin
      _JENKINS_PASSWD=novell

      java -jar ./jenkins-cli.jar -s “$_JENKINS_URL” -auth “$_JENKINS_USER:$_JENKINS_PASSWD” -noKeyAuth list-plugins| grep -e ‘)$’ | awk ‘{ print $1 }’| while read _UPDATE_LIST;
      do
      java -jar jenkins-cli.jar -s “$_JENKINS_URL” -auth “$_JENKINS_USER:$_JENKINS_PASSWD” -noKeyAuth install-plugin “$_UPDATE_LIST”;
      done

      java -jar jenkins-cli.jar -s “$_JENKINS_URL” -auth “$_JENKINS_USER:$_JENKINS_PASSWD” -noKeyAuth safe-restart;

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

configure: error: C++ compiler cannot create executables

How to use grep command to get fixed pattern or exact keyword

How to page scroll up/down in Linux terminal

Non interactive ,without typing password do ssh to Server : By sshpass

Set GRUB password after installation of CentOS/Red Hat

This kernel requires an x86-64 CPU but only detected an i686 CPU

Show visitor ip address php code

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ·
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy