Answers: <p>One could use ansible geerlingguy.jenkins role. When this role is applied, a Jenkins system will be created without any plugins. Subsequently, one could install plugins manually, but also define them in ansible, i.e. plugins as code.</p>
  
Answers: CC BY-SA 3.0
Answers: 2018-03-08T22:06:16.700Z
Answers: 2018-03-08T23:23:10.103Z
Answers: 2018-03-08T23:23:10.103Z
Answers: 030
Answers: <p>One could also use docker Jenkins LTS. If one wants to start from scratch, just remove the mounted Jenkins home folder and there will be a clean Jenkins in no time.</p>
  
  <p><a href="https://github.com/jenkinsci/docker/blob/master/README.md" rel="nofollow noreferrer">https://github.com/jenkinsci/docker/blob/master/README.md</a></p>
  
Answers: CC BY-SA 3.0
Answers: 2018-03-09T18:33:36.773Z
Answers: Yup, I have used this procedure sometimes back, still using some cases. I'm just curious to know is there a native way of doing this.
Answers: Buvanesh Kumar
Answers: CC BY-SA 4.0
Answers: 2019-11-12T18:05:03.997Z
Answers: You could mount the docker image and attach your jenkins home folder to it. Then you can run a script/program/whatever that compares the plugins and deletes the ones that are in your jenkins home but not in the docker container's jenkins home.
Answers: Lee Meador
Answers: CC BY-SA 3.0
Answers: 2018-03-09T18:10:40.690Z
Answers: 2018-03-09T18:10:40.690Z
Answers: 030
Answers: <p>One possible approach, although a bit tedious (and a bit dumb), would be to:</p>
  
  <ul>
  <li>make a fresh Jenkins installation of the exact same version on another (maybe scrappable) machine</li>
  <li>get the list of the (default) plugins it ends up with</li>
  <li>add/remove/update the plugins in the original Jenkins installation to match that list</li>
  </ul>
  
Answers: CC BY-SA 3.0
Answers: 2018-03-09T00:12:27.337Z
Answers: 2018-03-09T00:12:27.337Z
Answers: Dan Cornilescu
Answers: <p>I find it strange that nobody mentioned the <a href="https://github.com/jenkinsci/configuration-as-code-plugin" rel="nofollow noreferrer">Configuration as Code</a> plugin. Our solution to this problem is to maintain a base Docker image for jenkins, provisioned with two config files:</p>
  
  <ul>
  <li>jenkins.yml</li>
  <li>plugins.txt</li>
  </ul>
  
  <p>The plugins are installed by the <code>install-plugins.sh</code> script provided by the base Jenkins image:</p>
  
  <pre><code>COPY casc_configs/plugins.txt /usr/share/jenkins/ref/plugins.txt
  COPY casc_configs/jenkins.yml /usr/share/jenkins/ref/jenkins.yml
  RUN /usr/local/bin/install-plugins.sh &lt; /usr/share/jenkins/ref/plugins.txt
  </code></pre>
  
  <p>and Jenkins itself is configured using the <code>jenkins.yml</code>.</p>
  
  <p>The plugin file is generated from a template:</p>
  
  <pre><code>{% for plugin in jenkins.plugins %}
  {{ plugin.name }}:{{ plugin.version }}
  {%endfor%}
  </code></pre>
  
  <p>where the variable <code>jenkins.plugins</code> is a big list of dicts:</p>
  
  <pre><code>jenkins:
    plugins:
      - name: configuration-as-code
        version: 1.14
  </code></pre>
  
  <p>Doing things this way makes it possible to create and destroy fully configured jenkins instances on the fly. If you want, you can keep the <code>jenkins.yml</code> and <code>plugins.txt</code> on a mount that Jenkins can read when it starts.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-10-29T11:15:17.083Z
Answers: 2019-10-29T11:15:17.083Z
Answers: Bruce Becker
Body: <p>I do a lot of testing in my Jenkins VM which I have on my local laptop. I found this time-consuming to remove Jenkins and installing again from scratch. It would be better if I have a simple way to restore my Jenkins.</p>
  
  <p>Is there a way to remove all the plugins that I have installed manually and keep the plugins that were installed during Jenkins installation? </p>
  
Comments: CC BY-SA 3.0
Comments: 2018-03-08T21:48:41.710Z
Comments: Why do you want that?
Comments: 030
Comments: CC BY-SA 3.0
Comments: 2018-03-08T22:01:04.613Z
Comments: I don't think there is a universal "one-click" button to restore default plugins. You can however download and search through the jenkins.war file of the version you installed and see the exact plugins with their versions that are bundled with that version.
Comments: Preston Martin
Comments: CC BY-SA 3.0
Comments: 2018-03-08T22:01:10.357Z
Comments: @030 I'm going to assume he is fed up with trying to figure out which plugins are causing him issues and wants to start from square 1 :)
Comments: Preston Martin
Comments: CC BY-SA 3.0
Comments: 2018-03-09T15:35:18.500Z
Comments: @030 I do a lot of testing in my Jenkins VM which I have on my local laptop. I found it time-consuming to remove Jenkins and installing again from scratch. It would be better if I have a simple way to restore my Jenkins in a simple way.
Comments: Buvanesh Kumar
Comments: CC BY-SA 3.0
Comments: 2018-03-09T18:31:54.187Z
Comments: @030 I have added the same :)
Comments: Buvanesh Kumar
Comments: CC BY-SA 4.0
Comments: 2019-10-29T09:16:48.983Z
Comments: Once you start installing any of the plugin, it automatically install the ones that are to be installed by default
Comments: Ajith Babu
Tags: <jenkins><jenkins-pipeline><jenkins-plugins><jenkins2><jcac>
Title: How to restore default Jenkins plugins?
UserDisplayName: Buvanesh Kumar
ThreadText: # How to restore default Jenkins plugins?
  
  (Asked by: username_0 on 2018-03-08)
  
  I do a lot of testing in my Jenkins VM which I have on my local laptop. I found this time-consuming to remove Jenkins and installing again from scratch. It would be better if I have a simple way to restore my Jenkins.
  
  Is there a way to remove all the plugins that I have installed manually and keep the plugins that were installed during Jenkins installation?
  
  **Tags:** jenkins, jenkins-pipeline, jenkins-plugins, jenkins2, jcac
  
  > **Comments:**
  > **username_1**: Why do you want that?  
  > **username_2**: I don't think there is a universal "one-click" button to restore default plugins. You can however download and search through the jenkins.war file of the version you installed and see the exact plugins with their versions that are bundled with that version.  
  > **username_2**: @username_1 I'm going to assume he is fed up with trying to figure out which plugins are causing him issues and wants to start from square 1 :)  
  > **username_0**: @username_1 I do a lot of testing in my Jenkins VM which I have on my local laptop. I found it time-consuming to remove Jenkins and installing again from scratch. It would be better if I have a simple way to restore my Jenkins in a simple way.  
  > **username_0**: @username_1 I have added the same :)  
  > **username_3**: Once you start installing any of the plugin, it automatically install the ones that are to be installed by default  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2018-03-08. Score: 2 | Accepted answer
  
  One could use ansible geerlingguy.jenkins role. When this role is applied, a Jenkins system will be created without any plugins. Subsequently, one could install plugins manually, but also define them in ansible, i.e. plugins as code.
  
  
  ---
  
  ### Answer by username_1 on 2018-03-09. Score: 3
  
  One could also use docker Jenkins LTS. If one wants to start from scratch, just remove the mounted Jenkins home folder and there will be a clean Jenkins in no time.
  
  <https://github.com/jenkinsci/docker/blob/master/README.md>
  
  > **Comments:**
  > **username_0**: Yup, I have used this procedure sometimes back, still using some cases. I'm just curious to know is there a native way of doing this.  
  > **username_4**: You could mount the docker image and attach your jenkins home folder to it. Then you can run a script/program/whatever that compares the plugins and deletes the ones that are in your jenkins home but not in the docker container's jenkins home.  
  
  ---
  
  ### Answer by username_5 on 2018-03-09. Score: 2
  
  One possible approach, although a bit tedious (and a bit dumb), would be to:
  
  * make a fresh Jenkins installation of the exact same version on another (maybe scrappable) machine
  * get the list of the (default) plugins it ends up with
  * add/remove/update the plugins in the original Jenkins installation to match that list
  
  
  ---
  
  ### Answer by username_6 on 2019-10-29. Score: 2
  
  I find it strange that nobody mentioned the [Configuration as Code](https://github.com/jenkinsci/configuration-as-code-plugin) plugin. Our solution to this problem is to maintain a base Docker image for jenkins, provisioned with two config files:
  
  * jenkins.yml
  * plugins.txt
  
  The plugins are installed by the `install-plugins.sh` script provided by the base Jenkins image:
  
  ```
  COPY casc_configs/plugins.txt /usr/share/jenkins/ref/plugins.txt
  COPY casc_configs/jenkins.yml /usr/share/jenkins/ref/jenkins.yml
  RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
  
  ```
  
  and Jenkins itself is configured using the `jenkins.yml`.
  
  The plugin file is generated from a template:
  
  ```
  {% for plugin in jenkins.plugins %}
  {{ plugin.name }}:{{ plugin.version }}
  {%endfor%}
  
  ```
  
  where the variable `jenkins.plugins` is a big list of dicts:
  
  ```
  jenkins:
    plugins:
      - name: configuration-as-code
        version: 1.14
  
  ```
  
  Doing things this way makes it possible to create and destroy fully configured jenkins instances on the fly. If you want, you can keep the `jenkins.yml` and `plugins.txt` on a mount that Jenkins can read when it starts.
  
  
  ---
  
  