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
95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,101 @@ 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.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

## 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.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

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.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

Example updated plugins.txt (with deprecated plugins removed):
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

```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. Rebuild the Jenkins image to apply the changes made in the plugins.txt file using the following command:
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

```
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:
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

```
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:

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

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

```
cd /usr/share/jenkins/
```
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

7. Check the plugins.txt file to ensure the references to the deprecated plugins are gone:
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

```
cat plugins.txt | grep <plugin-name>
```
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

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 in your web browser. Log in with your admin credentials.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

9. Navigate to Manage Jenkins and select Manage Plugins.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

10. In the Installed tab, search for the name of the deprecated plugin you want to uninstall.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

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 and search that plugin and remove it first.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

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.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

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:
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

- 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.
ritikbanger marked this conversation as resolved.
Show resolved Hide resolved

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

### 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