From f7d23bedb64dae1235adacecec116200a205d9ed Mon Sep 17 00:00:00 2001 From: Ritik Banger Date: Sun, 25 Dec 2022 14:06:43 +0530 Subject: [PATCH 1/6] added uninstalling a plugin methods --- README.md | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/README.md b/README.md index f0737b79e7..9b1123e9d4 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,116 @@ 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 Plugins + +**To uninstall a plugin in Jenkins using the web UI, follow these steps:** + +- Open Jenkins in your web browser and log in as an administrator. +- Click on the "Manage Jenkins" link in the left menu. +- Click on the "Manage Plugins" link. +- In the "Installed" tab, find the plugin you want to uninstall and click on the checkbox next to it. +- Click on the "Uninstall" button at the bottom of the page. +- A message will appear asking you to confirm the uninstallation. Click on the "Yes" button to confirm. + +Jenkins will uninstall the plugin and restart the server to apply the changes. Once the server has restarted, the plugin will be uninstalled and will no longer be available in Jenkins. + +**To uninstall a plugin in Jenkins using the CLI, follow these steps:** + +- Open a terminal window and connect to your Jenkins server using the ssh command. For example: + +`ssh jenkins@your-server-name` + +- Once you are logged in to the Jenkins server, enter the following command to list all the installed plugins: + +`java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins` + +- Find the short name of the plugin you want to uninstall from the list of installed plugins. The short name is the name of the plugin as it appears in the `.hpi` or `.jpi` file, without the file extension. + +- To uninstall the plugin, enter the following command, replacing `PLUGIN_SHORT_NAME` with the short name of the plugin you want to uninstall: + +`java -jar jenkins-cli.jar -s http://localhost:8080/ uninstall-plugin PLUGIN_SHORT_NAME` + +- Jenkins will uninstall the plugin and restart the server to apply the changes. Once the server has restarted, the plugin will be uninstalled and will no longer be available in Jenkins. + +**Note**: Some plugins may have dependencies on other plugins, which means that uninstalling one plugin may also uninstall other plugins that depend on it. Make sure to carefully review the list of plugins that will be uninstalled before confirming the uninstallation. + +To check the dependencies, use the following command: + +`java -jar jenkins-cli.jar -s http://localhost:8080/ list-dependencies PLUGIN_SHORT_NAME` + +Replace `PLUGIN_SHORT_NAME` with the short name of the plugin you want to check the dependencies for. The command will output a list of the plugins that the selected plugin is dependent on. + +**To remove a plugin from Jenkins using a custom Dockerfile, you can follow these steps:** + +- Create a file called `plugins.txt` in the root directory of your Jenkins project. This file should contain the short names of the plugins you want to remove, one plugin per line. +- In your Dockerfile, add the following command to copy the plugins.txt file into the Jenkins container: + +`COPY plugins.txt /usr/share/jenkins/ref/` + +- Add the following command to your Dockerfile to remove the plugins specified in the `plugins.txt` file: + +`RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt` + +- Build your Docker image and run the container. The plugins specified in the plugins.txt file will be removed from Jenkins. + +Here is an example of a Dockerfile that can be used to remove the "WMI" windows-slave plugin from Jenkins: + +Create the custom Dockerfile: + +```DockerFile +FROM jenkins/jenkins:latest + +# Copy the plugins.txt file into the Jenkins container +COPY plugins.txt /usr/share/jenkins/ref/ + +# Remove the plugins specified in the plugins.txt file +RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt +``` + +In this example, the `plugins.txt` file should contain the following line: + +`wmi-windows-slaves` + +When you build the Docker image and run the container, the "WMI" windows-slave plugin will be removed from Jenkins. + +Note that when you uninstall a plugin from Jenkins, the plugin files are not deleted from the `$JENKINS_HOME/plugins/` directory by default. This is because the `$JENKINS_HOME` directory is typically used as a data volume or bind mounted volume, and deleting the plugin files could potentially cause data loss or other issues. + +To completely remove the plugin from Jenkins, you will need to delete the plugin files from the `$JENKINS_HOME/plugins` directory and restart the Jenkins container. You can do this by manually deleting the files and restarting the container using the command line. + +**To remove the plugin files using the command line, follow these steps:** + +- Connect to the Jenkins server using the ssh command. +- Navigate to the `$JENKINS_HOME/plugins/` directory using the `cd $JENKINS_HOME/plugins/` command. +- Find the plugin files you want to delete. The plugin files are typically named after the short name of the plugin, with a `.hpi` or `.jpi` file extension. +- Use the `rm` command to delete the plugin files: `rm PLUGIN_SHORT_NAME.hpi` +- Restart the Jenkins container to apply the changes: `docker restart jenkins` + +Once the plugin files have been deleted and the Jenkins container has been restarted, the plugin will be completely removed from Jenkins. + +## Self-Diagonosis + +To self-diagnose the plugin removal step in your Jenkins setup, you can follow these steps: + +- Connect to the Jenkins server using the command line interface (CLI). This can be done using the ssh command, for example: + +`ssh jenkins@your-server-name` + +- Once you are logged in to the Jenkins server, you can use the following command to list all the installed plugins: + +`java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins` + +- Check the list of installed plugins and verify that the plugin you intended to remove is not present. If the plugin is still listed, it has not been successfully removed. + +- If the plugin is still present, you can try uninstalling it using the Jenkins web UI or the jenkins-cli tool as described above. + +- If the plugin is still present after attempting to uninstall it, you may need to check for any dependencies that the plugin has on other plugins. Some plugins may not be able to be uninstalled if they are required by other plugins. In this case, you will need to uninstall the dependent plugins first. + +- You can also check the `/usr/share/jenkins/ref/plugins` directory to verify that the plugin files are no longer present. If the plugin files are still present in this directory, the plugin has not been successfully removed. + +- If you are using a custom Dockerfile to remove the plugins, you can check the Dockerfile and the `plugins.txt` file to make sure that the plugin removal steps are correctly configured. You can also check the build logs for any errors or issues that may have occurred during the build process. + +By following these steps, you should be able to diagnose and troubleshoot any issues with plugin removal in your Jenkins setup. + ### 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` From 033ac90efac6e8fda1f3e388f3729943ee06b4c6 Mon Sep 17 00:00:00 2001 From: Ritik Banger Date: Mon, 26 Dec 2022 10:28:37 +0530 Subject: [PATCH 2/6] typo fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b1123e9d4..64b249895d 100644 --- a/README.md +++ b/README.md @@ -350,7 +350,7 @@ To completely remove the plugin from Jenkins, you will need to delete the plugin Once the plugin files have been deleted and the Jenkins container has been restarted, the plugin will be completely removed from Jenkins. -## Self-Diagonosis +## Self-Diagnosis To self-diagnose the plugin removal step in your Jenkins setup, you can follow these steps: From b0b6bcf1363f984983d02f4208cb8ffe3e6a9183 Mon Sep 17 00:00:00 2001 From: Ritik Banger Date: Thu, 29 Dec 2022 19:31:39 +0530 Subject: [PATCH 3/6] refactor: updating the plugins.txt would uninstall the plugin instead of creating a new plugin.txt --- README.md | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 64b249895d..ac9bfd3ae6 100644 --- a/README.md +++ b/README.md @@ -305,16 +305,16 @@ Replace `PLUGIN_SHORT_NAME` with the short name of the plugin you want to check **To remove a plugin from Jenkins using a custom Dockerfile, you can follow these steps:** -- Create a file called `plugins.txt` in the root directory of your Jenkins project. This file should contain the short names of the plugins you want to remove, one plugin per line. +- While installing the plugins, you will need to create a file called `plugins.txt` in the root directory of your Jenkins project. Remove the plugin name from this file which you wish to uninstall. - In your Dockerfile, add the following command to copy the plugins.txt file into the Jenkins container: `COPY plugins.txt /usr/share/jenkins/ref/` -- Add the following command to your Dockerfile to remove the plugins specified in the `plugins.txt` file: +- Add the following command to your Dockerfile to uninstall the plugins that you removed from the `plugins.txt` file: -`RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt` +`RUN jenkins-plugin-cli --clean-download-directory` -- Build your Docker image and run the container. The plugins specified in the plugins.txt file will be removed from Jenkins. +- Build your Docker image and run the container. The plugins removed from the plugins.txt file will be uninstalled from Jenkins. Here is an example of a Dockerfile that can be used to remove the "WMI" windows-slave plugin from Jenkins: @@ -324,13 +324,13 @@ Create the custom Dockerfile: FROM jenkins/jenkins:latest # Copy the plugins.txt file into the Jenkins container -COPY plugins.txt /usr/share/jenkins/ref/ +COPY --chown=jenkins:jenkins plugins.txt $REF/plugins.txt -# Remove the plugins specified in the plugins.txt file -RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt +# Remove the plugins not exist in plugins.txt file +RUN jenkins-plugin-cli --plugin-file $REF/plugins.txt ``` -In this example, the `plugins.txt` file should contain the following line: +In this example, update the `plugins.txt` file by removing the following line: `wmi-windows-slaves` @@ -338,7 +338,7 @@ When you build the Docker image and run the container, the "WMI" windows-slave p Note that when you uninstall a plugin from Jenkins, the plugin files are not deleted from the `$JENKINS_HOME/plugins/` directory by default. This is because the `$JENKINS_HOME` directory is typically used as a data volume or bind mounted volume, and deleting the plugin files could potentially cause data loss or other issues. -To completely remove the plugin from Jenkins, you will need to delete the plugin files from the `$JENKINS_HOME/plugins` directory and restart the Jenkins container. You can do this by manually deleting the files and restarting the container using the command line. +To completely remove the plugin from Jenkins, you will need to delete the pluginspecified in the files from the `$JENKINS_HOME/plugins` directory and restart the Jenkins container. You can do this by manually deleting the files and restarting the container using the command line. **To remove the plugin files using the command line, follow these steps:** @@ -350,6 +350,17 @@ To completely remove the plugin from Jenkins, you will need to delete the plugin Once the plugin files have been deleted and the Jenkins container has been restarted, the plugin will be completely removed from Jenkins. +**To remove a plugin from a Jenkins instance that is using a data volume to preserve the configuration, follow these steps:** + +- Remove the plugin from the `plugins.txt` file. +- Rebuild the Docker image using the updated `plugins.txt` file. +- Stop the existing Jenkins container. +- Remove the plugin files from the `$JENKINS_HOME/plugins/` directory in the data volume. +- You can do this by attaching the data volume to another container and deleting the plugin files directly, or by using a tool such as `rsync` to delete the files from the host machine. +- Start the Jenkins container using the updated Docker image. + +This process will ensure that the Jenkins instance is using the updated set of plugins specified in the `plugins.txt` file. + ## Self-Diagnosis To self-diagnose the plugin removal step in your Jenkins setup, you can follow these steps: From 363bddd64445fd6bf14a70fa625ab7ca8bb53b83 Mon Sep 17 00:00:00 2001 From: Ritik Banger Date: Sat, 15 Jul 2023 22:31:17 +0530 Subject: [PATCH 4/6] updated deprecated plugin removal --- README.md | 140 ++++++++++++++++++++++-------------------------------- 1 file changed, 57 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 5360900674..bfc4bc2247 100644 --- a/README.md +++ b/README.md @@ -264,126 +264,100 @@ 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 Plugins +# Uninstalling Deprecated Plugins in Jenkins (with Docker) -**To uninstall a plugin in Jenkins using the web UI, follow these steps:** +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. -- Open Jenkins in your web browser and log in as an administrator. -- Click on the "Manage Jenkins" link in the left menu. -- Click on the "Manage Plugins" link. -- In the "Installed" tab, find the plugin you want to uninstall and click on the checkbox next to it. -- Click on the "Uninstall" button at the bottom of the page. -- A message will appear asking you to confirm the uninstallation. Click on the "Yes" button to confirm. +## Prerequisites -Jenkins will uninstall the plugin and restart the server to apply the changes. Once the server has restarted, the plugin will be uninstalled and will no longer be available in Jenkins. +- Docker and Docker Compose are installed on your system. +- Basic knowledge of Docker and Jenkins. -**To uninstall a plugin in Jenkins using the CLI, follow these steps:** +## Steps -- Open a terminal window and connect to your Jenkins server using the ssh command. For example: +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. -`ssh jenkins@your-server-name` +Example content of `plugins.txt`: -- Once you are logged in to the Jenkins server, enter the following command to list all the installed plugins: - -`java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins` - -- Find the short name of the plugin you want to uninstall from the list of installed plugins. The short name is the name of the plugin as it appears in the `.hpi` or `.jpi` file, without the file extension. - -- To uninstall the plugin, enter the following command, replacing `PLUGIN_SHORT_NAME` with the short name of the plugin you want to uninstall: - -`java -jar jenkins-cli.jar -s http://localhost:8080/ uninstall-plugin PLUGIN_SHORT_NAME` - -- Jenkins will uninstall the plugin and restart the server to apply the changes. Once the server has restarted, the plugin will be uninstalled and will no longer be available in Jenkins. - -**Note**: Some plugins may have dependencies on other plugins, which means that uninstalling one plugin may also uninstall other plugins that depend on it. Make sure to carefully review the list of plugins that will be uninstalled before confirming the uninstallation. - -To check the dependencies, use the following command: - -`java -jar jenkins-cli.jar -s http://localhost:8080/ list-dependencies PLUGIN_SHORT_NAME` - -Replace `PLUGIN_SHORT_NAME` with the short name of the plugin you want to check the dependencies for. The command will output a list of the plugins that the selected plugin is dependent on. - -**To remove a plugin from Jenkins using a custom Dockerfile, you can follow these steps:** - -- While installing the plugins, you will need to create a file called `plugins.txt` in the root directory of your Jenkins project. Remove the plugin name from this file which you wish to uninstall. -- In your Dockerfile, add the following command to copy the plugins.txt file into the Jenkins container: - -`COPY plugins.txt /usr/share/jenkins/ref/` - -- Add the following command to your Dockerfile to uninstall the plugins that you removed from the `plugins.txt` file: +```plaintext +# See https://github.com/jenkinsci/docker#usage-1 +ant:1.11 +bootstrap4-api:4.6.0-3 +popper-js:2.9.2-1 +``` -`RUN jenkins-plugin-cli --clean-download-directory` +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. -- Build your Docker image and run the container. The plugins removed from the plugins.txt file will be uninstalled from Jenkins. +Example updated plugins.txt (with deprecated plugins removed): -Here is an example of a Dockerfile that can be used to remove the "WMI" windows-slave plugin from Jenkins: +```plaintext +# See https://github.com/jenkinsci/docker#usage-1 +ant:1.11 +``` -Create the custom Dockerfile: +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: -```DockerFile -FROM jenkins/jenkins:latest +``` +docker-compose build jenkins +``` -# Copy the plugins.txt file into the Jenkins container -COPY --chown=jenkins:jenkins plugins.txt $REF/plugins.txt +4. Recreate the Jenkins Container: Once the image is successfully rebuilt, recreate the Jenkins container using the updated image. Use the following command: -# Remove the plugins not exist in plugins.txt file -RUN jenkins-plugin-cli --plugin-file $REF/plugins.txt +``` +docker-compose up -d --build --force-recreate jenkins ``` -In this example, update the `plugins.txt` file by removing the following line: - -`wmi-windows-slaves` +5. Verify Plugin Removal: To verify if the deprecated plugins have been removed, enter the running Jenkins container by executing the following command: -When you build the Docker image and run the container, the "WMI" windows-slave plugin will be removed from Jenkins. +``` +docker-compose exec jenkins bash +``` -Note that when you uninstall a plugin from Jenkins, the plugin files are not deleted from the `$JENKINS_HOME/plugins/` directory by default. This is because the `$JENKINS_HOME` directory is typically used as a data volume or bind mounted volume, and deleting the plugin files could potentially cause data loss or other issues. +6. Once inside the container, navigate to the Jenkins plugin directory: -To completely remove the plugin from Jenkins, you will need to delete the pluginspecified in the files from the `$JENKINS_HOME/plugins` directory and restart the Jenkins container. You can do this by manually deleting the files and restarting the container using the command line. +``` +cd /usr/share/jenkins/ +``` -**To remove the plugin files using the command line, follow these steps:** +7. Check the plugins.txt file to ensure the references to the deprecated plugins are gone: -- Connect to the Jenkins server using the ssh command. -- Navigate to the `$JENKINS_HOME/plugins/` directory using the `cd $JENKINS_HOME/plugins/` command. -- Find the plugin files you want to delete. The plugin files are typically named after the short name of the plugin, with a `.hpi` or `.jpi` file extension. -- Use the `rm` command to delete the plugin files: `rm PLUGIN_SHORT_NAME.hpi` -- Restart the Jenkins container to apply the changes: `docker restart jenkins` +``` +cat plugins.txt | grep +``` -Once the plugin files have been deleted and the Jenkins container has been restarted, the plugin will be completely removed from Jenkins. +Replace 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. -**To remove a plugin from a Jenkins instance that is using a data volume to preserve the configuration, follow these steps:** +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. -- Remove the plugin from the `plugins.txt` file. -- Rebuild the Docker image using the updated `plugins.txt` file. -- Stop the existing Jenkins container. -- Remove the plugin files from the `$JENKINS_HOME/plugins/` directory in the data volume. -- You can do this by attaching the data volume to another container and deleting the plugin files directly, or by using a tool such as `rsync` to delete the files from the host machine. -- Start the Jenkins container using the updated Docker image. +9. Navigate to Manage Jenkins and select Manage Plugins. -This process will ensure that the Jenkins instance is using the updated set of plugins specified in the `plugins.txt` file. +10. In the Installed tab, search for the name of the deprecated plugin you want to uninstall. -## Self-Diagnosis +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. -To self-diagnose the plugin removal step in your Jenkins setup, you can follow these steps: +12. Confirm the removal when prompted. -- Connect to the Jenkins server using the command line interface (CLI). This can be done using the ssh command, for example: +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. -`ssh jenkins@your-server-name` +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: -- Once you are logged in to the Jenkins server, you can use the following command to list all the installed plugins: +- Enter the running Jenkins container using the command mentioned in step 5. +- Navigate to the plugin directory: -`java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins` +`cd ~/plugins` -- Check the list of installed plugins and verify that the plugin you intended to remove is not present. If the plugin is still listed, it has not been successfully removed. +- List the contents of the directory to identify the remnants of the deprecated plugins: -- If the plugin is still present, you can try uninstalling it using the Jenkins web UI or the jenkins-cli tool as described above. +`ls -artl *` -- If the plugin is still present after attempting to uninstall it, you may need to check for any dependencies that the plugin has on other plugins. Some plugins may not be able to be uninstalled if they are required by other plugins. In this case, you will need to uninstall the dependent plugins first. +- Remove the remnants of the deprecated plugins using the rm command. For example: -- You can also check the `/usr/share/jenkins/ref/plugins` directory to verify that the plugin files are no longer present. If the plugin files are still present in this directory, the plugin has not been successfully removed. +`rm -fr *` -- If you are using a custom Dockerfile to remove the plugins, you can check the Dockerfile and the `plugins.txt` file to make sure that the plugin removal steps are correctly configured. You can also check the build logs for any errors or issues that may have occurred during the build process. +Replace with the name of the deprecated plugin you want to remove. -By following these steps, you should be able to diagnose and troubleshoot any issues with plugin removal in your Jenkins setup. +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 From 427f878f6b1c58e049f2e789b51547ca92443293 Mon Sep 17 00:00:00 2001 From: Ritik Banger Date: Sat, 5 Aug 2023 13:43:41 +0530 Subject: [PATCH 5/6] requested changes in formatting --- README.md | 55 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index bfc4bc2247..a5a9d19bf2 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,8 @@ 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. +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 @@ -275,7 +276,9 @@ This guide provides detailed instructions on how to uninstall deprecated plugins ## 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. +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`: @@ -286,61 +289,71 @@ 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. +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): +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. Rebuild the Jenkins image to apply the changes made in the plugins.txt file using the following command: +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: -``` +```bash docker-compose build jenkins ``` -4. Recreate the Jenkins Container: Once the image is successfully rebuilt, recreate the Jenkins container using the updated image. Use the following command: +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 ``` 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: +7. Check the `plugins.txt` file to ensure the references to the deprecated plugins are gone: -``` +```bash cat plugins.txt | grep ``` -Replace 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. +Replace `` 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. -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. +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. +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. +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 and search that plugin and remove it first. +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. +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: +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: @@ -355,7 +368,7 @@ Replace with the name of the deprecated plugin you want to uninsta `rm -fr *` -Replace with the name of the deprecated plugin you want to remove. +Replace `` 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/). From 06377cdb9fe00aa55bc2de67e973a11a2be2d5ab Mon Sep 17 00:00:00 2001 From: Ritik Banger Date: Sat, 6 Jul 2024 23:32:32 +0530 Subject: [PATCH 6/6] removed docker compose, added adminition --- README.md | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index cff66ae6fa..7f62ffb3e8 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,9 @@ Removing deprecated plugins is crucial to maintain the security and stability of - Docker and Docker Compose are installed on your system. - Basic knowledge of Docker and Jenkins. +> [!IMPORTANT] +> The plugins installed in Jenkins reside in a Docker volume, which has a different lifecycle than the container image. The container image's entrypoint does NOT automatically clean up plugins. Manual removal is necessary to ensure complete uninstallation. + ## Steps 1. **Locate `plugins.txt`**: Find the `plugins.txt` file in your Jenkins Docker setup. @@ -303,59 +306,49 @@ Example updated `plugins.txt` (with deprecated plugins removed): 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: +3. **Rebuild the Jenkins Container Image**: In your terminal, navigate to the directory containing the Jenkins Container Image definition. Rebuild the Jenkins image to apply the changes made in the plugins.txt file using Docker: ```bash -docker-compose build jenkins +docker build -t my-jenkins . ``` 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 -``` - -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 +docker run -d --name jenkins -p 8080:8080 my-jenkins ``` -6. Once inside the container, navigate to the Jenkins plugin directory: +5. Verify effective plugins removal: To verify if the deprecated plugins have been removed from the image, check their absence from the `/usr/share/jenkins/plugins.txt` in the running Jenkins container. +For instance, if you use `docker`: ```bash -cd /usr/share/jenkins/ +docker exec grep -c "" /usr/share/jenkins/plugins.txt +0 # Should be zero (e.g. the number of occurences of the string "" in the file) ``` +Replace `` with the name of the deprecated plugin you want to uninstall. If the result is 0, it means the plugin references have been removed successfully. -7. Check the `plugins.txt` file to ensure the references to the deprecated plugins are gone: - -```bash -cat plugins.txt | grep -``` - -Replace `` 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. - -8. Uninstall Plugins in the Jenkins UI: Access the Jenkins web interface by visiting [http://localhost:8080](http://localhost:8080) in your web browser. +6. 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_. +7. 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. +8. 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. +9. 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. +10. Confirm the removal when prompted. -13. Restart Jenkins: To complete the removal process, Jenkins needs to be restarted. +11. 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: +> [!NOTE] +> The Jenkins UI can be used for plugin removal, but it does not always remove all associated files. For thorough removal, use the command line method described above. + +12. 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: