# Plugin installation via automation fails

**URL:** <https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295>\
**Category:** Ask a question\
**Tags:** question\
**Created:** [May 20, 2024, 11:45am UTC](https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295 "2024-05-20T11:45:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karmugilan\_Devops](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@Karmugilan\_Devops](https://community.jenkins.io/u/Karmugilan_Devops)\
**Post date:** [May 20, 2024, 11:45am UTC](https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295/1 "2024-05-20T11:45:37Z")

</div>

Now Latest Release Jenkins, new installation of Jenkins getting failed to Run, Plugin installation via automation getting failed! Jenkins through error’s to run.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [May 20, 2024, 12:27pm UTC](https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295/2 "2024-05-20T12:27:08Z")

</div>

You’ll need to provide more details about your environment and the failure message that is being reported.

“it doesn’t work” is always hard to remote debug. Try to always include these 3 things.

1. what did you try? (Code samples, command lines, screenshots, videos, etc)
2. what did happen? (Error messages, description, outputs, stuff)
3. what did you expect to happen?

Otherwise, it’s hard for us to get into your context and you’ll have to have someone who is exactly knowledgeable come along.

---

<div class="post-metadata">

**Author:** ![Karmugilan\_Devops](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@Karmugilan\_Devops](https://community.jenkins.io/u/Karmugilan_Devops)\
**Post date:** [May 21, 2024, 9:09am UTC](https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295/3 "2024-05-21T09:09:00Z")

</div>

what did you try? (Code samples, command lines, screenshots, videos, etc)  
we are doing some automation using Jenkins ci.  
1. Install plugin using bash script  
#!/bin/bash  
JENKINS\_URL=“[http://localhost:8080](http://localhost:8080)”  
JENKINS\_CLI\_JAR=“jenkins-cli.jar”  
JENKINS\_USER=“your-username”  
JENKINS\_TOKEN=“your-api-token”  
DEFAULT\_PLUGINS=(  
“ldap”  
“job-dsl”  
“ssh-credentials”  
“docker-workflow”  
“ant”  
“build-timeout”  
“credentials-binding”  
“email-ext”  
“github-organization-folder”  
“gradle”  
“workflow-aggregator”  
“configuration-as-code”  
)  
# Download Jenkins CLI if not already present  
if [! -f “$JENKINS\_CLI\_JAR”]; then  
wget “$JENKINS\_URL/jnlpJars/JENKINS\_CLI\_JAR" fi # Install each plugin for plugin in "{DEFAULT\_PLUGINS[@]}”; do  
java -jar $JENKINS\_CLI\_JAR -s $JENKINS\_URL -auth $JENKINS\_USER:$JENKINS\_TOKEN install-plugin $plugin -deploy  
done  
# Restart Jenkins to apply changes  
java -jar $JENKINS\_CLI\_JAR -s $JENKINS\_URL -auth $JENKINS\_USER:$JENKINS\_TOKEN safe-restart  
what did happen? (Error messages, description, outputs, stuff)  
when we try to install jenkins and plugins that time we face jenkins server getting crashed  
what did you expect to happen?  
Jenkins - jenkins installation with plugin via ansible automation and bash script automation in RHEL and UBUNTU  
we need to fix this error and need a reason why jenkins service crashed.  
Note: we expect complete jenkins install through automation we need.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [May 21, 2024, 12:42pm UTC](https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295/4 "2024-05-21T12:42:53Z")

</div>

> [@Karmugilan\_Devops](#):
>
> when we try to install jenkins and plugins that time we face jenkins server getting crashed

What messages does Jenkins report when it crashes?

The operations you’re performing seem reasonable to me. The Jenkins command line is able to install plugins and the installed plugins should support the version of the Jenkins controller that you are running, so long as that Jenkins controller is supported by the Jenkins update center.

## An alternate idea

It is surprising to me that you are attempting to manage your configuration as code without specifying all the plugins you are installing and without specifying the precise versions of the plugins that you are installing. That will give you an unpredictable configuration, since you’ll always receive the most recent releases of the plugin at the time you install the plugins.

I like to specify the exact plugins and their versions so that the configuration is repeatable no matter when I run that configuration. I believe that many other Jenkins administrators do the same.

In my case, I have a [`plugins.txt` file](https://github.com/MarkEWaite/docker-lfs/blob/06c9ad7e94253f2d3883ee2b6ecc7f75cd1a6d56/plugins.txt) that is maintained by a [Python script](https://github.com/MarkEWaite/docker-lfs/blob/06c9ad7e94253f2d3883ee2b6ecc7f75cd1a6d56/update_plugins.py). I [build](https://github.com/MarkEWaite/docker-lfs/blob/06c9ad7e94253f2d3883ee2b6ecc7f75cd1a6d56/docker_build.py) a Docker container image for the configuration that I want to evaluate, then I use `docker run` to run that container image on the computer where I created it.

I’m sure others have better techniques that they use to manage their plugin versions, but that method has worked well for me.

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [May 21, 2024, 1:11pm UTC](https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295/5 "2024-05-21T13:11:41Z")

</div>

Doing it more or less the same since over 8 years. A config file with the plugins I need with the exact versions and then build a docker image out of it for a dedicated Jenkins version.

---

<div class="post-metadata">

**Author:** ![Karmugilan\_Devops](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@Karmugilan\_Devops](https://community.jenkins.io/u/Karmugilan_Devops)\
**Post date:** [May 23, 2024, 9:53am UTC](https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295/6 "2024-05-23T09:53:07Z")

</div>

Hi,  
Our Developement at end stage we cant able add docker type installation, that’s why we need Jenkins installation with plugin’s using ansible without any issues.

Regards,  
Karmugilan. K  
Senior Software Engineer  
YozY Technologies LLP

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [May 24, 2024, 6:32pm UTC](https://community.jenkins.io/t/plugin-installation-via-automation-fails/15295/7 "2024-05-24T18:32:45Z")

</div>

> [@Karmugilan\_Devops](#):
>
> Our Developement at end stage we cant able add docker type installation, that’s why we need Jenkins installation with plugin’s using ansible without any issues.

The technique that @mawinter69 and I are using to manage our plugins is not limited to container installations. However, it is quite different from the approach that you are taking.

Your approach:

- List a subset of the plugins without specifying a version number of the plugin and without specifying any of the dependencies of the plugin

Our approach:

- List all plugins with version numbers, including all plugin dependencies

Your approach:

- Use the Jenkins command line interface to use a running Jenkins to download the plugins into the running Jenkins controller

My approach:

- Use the Jenkins plugin installation manager tool to download the plugins into a directory that can be used as I start and stop a Jenkins controller to test that set of plugins

I’ve found it easier to use a container image, because I have many other files that benefit from being inside a container image. However, you can use the same technique without using a container image.

Outside of a container image, here is the shell script that I use to download and run a specified version of Jenkins and all the plugins specified in a `plugins.txt` file:

```bash
#!/bin/bash

JENKINS_WAR_VERSION=2.452.1
JENKINS_WAR=jenkins-${JENKINS_WAR_VERSION}.war
PLUGIN_MANAGER_VERSION=2.13.0
PLUGIN_MANAGER_JAR=jenkins-plugin-manager-${PLUGIN_MANAGER_VERSION}.jar

if [! -f ../$PLUGIN_MANAGER_JAR]; then
  base=https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download
  wget ${base}/${PLUGIN_MANAGER_VERSION}/$PLUGIN_MANAGER_JAR
  mv $PLUGIN_MANAGER_JAR ..
fi
if [! -d plugins]; then
  mkdir plugins
fi
java -jar ../$PLUGIN_MANAGER_JAR \
    --jenkins-version $JENKINS_WAR_VERSION \
    --latest false \
    --plugin-download-directory plugins \
    --plugin-file plugins.txt

if [! -f ../$JENKINS_WAR]; then
  base=https://get.jenkins.io/war-stable
  wget ${base}/${JENKINS_WAR_VERSION}/jenkins.war
  mv jenkins.war ../$JENKINS_WAR
fi

JENKINS_HOME=. java -jar ../$JENKINS_WAR

```
