Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninstalling a plugin #1531 #1538

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,114 @@ to indicate that this Jenkins installation is fully configured.
Otherwise a banner will appear prompting the user to install additional plugins,
which may be inappropriate.

# Uninstalling Deprecated Plugins in Jenkins (with Docker)

This guide provides detailed instructions on how to uninstall deprecated plugins in Jenkins when using Docker.
Removing deprecated plugins is crucial to maintain the security and stability of your Jenkins instance.

## Prerequisites

- Docker and Docker Compose are installed on your system.
- Basic knowledge of Docker and Jenkins.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

## Steps

1. **Locate `plugins.txt`**: Find the `plugins.txt` file in your Jenkins Docker setup.
This file defines the plugins installed in your Jenkins instance.
It can be found in the Dockerfile or a related configuration directory.

Example content of `plugins.txt`:

```plaintext
# See https://github.com/jenkinsci/docker#usage-1
ant:1.11
bootstrap4-api:4.6.0-3
popper-js:2.9.2-1
```

2. **Update plugins.txt**: Open the `plugins.txt` file and identify the plugins that are deprecated.
These plugins are indicated by the deprecation warning or message in the Jenkins UI.
Remove the lines corresponding to the deprecated plugins from the `plugins.txt` file.
Save the changes.

Example updated `plugins.txt` (with deprecated plugins removed):

```plaintext
# See https://github.com/jenkinsci/docker#usage-1
ant:1.11
```

3. **Rebuild the Jenkins Image**: In your terminal, navigate to the directory containing the Docker configuration files for your Jenkins instance.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved
Rebuild the Jenkins image to apply the changes made in the plugins.txt file using the following command:

```bash
docker-compose build jenkins
```
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

4. Recreate the Jenkins Container: Once the image is successfully rebuilt, recreate the Jenkins container using the updated image.
Use the following command:

```bash
docker-compose up -d --build --force-recreate jenkins
```
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

5. Verify Plugin Removal: To verify if the deprecated plugins have been removed, enter the running Jenkins container by executing the following command:

```bash
docker-compose exec jenkins bash
```

6. Once inside the container, navigate to the Jenkins plugin directory:

```bash
cd /usr/share/jenkins/
```

7. Check the `plugins.txt` file to ensure the references to the deprecated plugins are gone:

```bash
cat plugins.txt | grep <plugin-name>
```

Replace `<plugin-name>` with the name of the deprecated plugin you want to uninstall.
If no results are returned, it means the plugin references have been removed successfully.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

8. Uninstall Plugins in the Jenkins UI: Access the Jenkins web interface by visiting [http://localhost:8080](http://localhost:8080) in your web browser.
Log in with your admin credentials.

9. Navigate to _Manage Jenkins_ and select _Manage Plugins_.

10. In the _Installed_ tab, search for the name of the deprecated plugin you want to uninstall.

11. If the plugin appears in the list, click the _Uninstall_ button (red cross) next to it.
If the button is disabled then it means that the plugin has a dependency on another plugin.
Just hover on the red cross to know the parent plugin.
Search that plugin and remove it first by following the same procedure.

12. Confirm the removal when prompted.

13. Restart Jenkins: To complete the removal process, Jenkins needs to be restarted.
Restart Jenkins by hitting the `/safeRestart` endpoint or using the Jenkins UI.

14. Optional: Remove Plugin remnants from Docker Volume: If you want to remove any remnants of the deprecated plugins from the Docker volume, follow these steps:

- Enter the running Jenkins container using the command mentioned in step 5.
- Navigate to the plugin directory:

`cd ~/plugins`

- List the contents of the directory to identify the remnants of the deprecated plugins:

`ls -artl *`

- Remove the remnants of the deprecated plugins using the rm command. For example:

`rm -fr <plugin-name>*`

Replace `<plugin-name>` with the name of the deprecated plugin you want to remove.

To deep dive into the removal, refer to this [guide](https://www.jenkins.io/blog/2023/06/20/remove-outdated-plugins-while-using-docker/).
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

### Access logs

To enable Jenkins user access logs from Jenkins home directory inside a docker container, set the `JENKINS_OPTS` environment variable value to `--accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/jenkins_home/logs/access_log`
Expand Down