A Jenkins that is never upgraded piles up known vulnerabilities; a Jenkins that is upgraded without a method ends up, sooner or later, with a morning of broken builds because one plugin stopped being compatible with another. Until now TecnoShop's docker-compose.yml used the jenkins/jenkins:lts-jdk21 tag "as is", and plugins were installed and updated by hand from the interface, so nobody could say exactly which version of each piece is running, let alone rebuild it identically. In this lesson you will get to know the Jenkins release cycle, build a reproducible custom image with a Dockerfile and a plugins.txt with pinned versions, and follow TecnoShop's safe upgrade procedure: backup, a jenkins-test test environment, a smoke test, a maintenance window with Prepare for Shutdown and a rollback plan. You will finish with ongoing maintenance: deprecated or unmaintained plugins, dependencies, cleaning up builds and workspaces, Manage Old Data and a schedule.

The Two Release Lines: Weekly and LTS

Line Frequency For whom Sample Docker tag
Weekly One release every week: 2.xxx Those who want the latest and accept more risk jenkins/jenkins:2.xxx-jdk21, jenkins/jenkins:jdk21
LTS (Long-Term Support) A new baseline every ~12 weeks, with .1, .2 and .3 releases at intervals of about 4 weeks Production jenkins/jenkins:2.xxx.y-lts-jdk21, jenkins/jenkins:lts-jdk21

How LTS works:

  • Roughly every 12 weeks, a weekly release that has already been proven is chosen as the baseline (for example, 2.xxx).
  • On top of it, 2.xxx.1, 2.xxx.2 and 2.xxx.3 are published; they only include selected bug and security fixes, with no new features.
  • Then the next baseline arrives and the previous one stops receiving fixes.

Security advisories can force an out-of-schedule release on both lines. TecnoShop uses LTS in production.

Before Upgrading: Changelog, Upgrade Guide and Java

Before changing versions, Laura always reads:

  1. The LTS changelog (on jenkins.io, LTS Changelog): what changes in each release between the current one and the target.
  2. The LTS upgrade guide (LTS Upgrade Guide): for each baseline, the changes that may require action (plugins that must be updated first, removed options, behavior changes). If you skip several baselines, read the section for each one.
  3. The security advisories published since the last upgrade, which may affect how urgent it is.

A key point is the Java requirements: every so often Jenkins drops support for a Java version (recent LTS releases require Java 17 or 21). With the -jdk21 image you do not have to do anything, because Java comes in the image, but you do need to:

  • Choose the image variant with the Java you want (-jdk21).
  • Check that the agents use a supported Java version: linux-agent-01 uses jenkins/inbound-agent:latest-jdk21, so it complies too.
  • If you install Jenkins from packages (apt, dnf), check the Java support policy on jenkins.io before upgrading: you will have to upgrade Java yourself.

From the Official Image to a Custom Image

The lts-jdk21 tag is a moving tag: today it points to one version and in a few weeks to another. With it:

  • A docker compose pull or a new machine can upgrade Jenkins without anyone deciding to.
  • You cannot go back precisely to "yesterday's version".
  • The plugins live only in the volume, installed by hand: the installation is not reproducible.

In production you pin a specific tag and build a custom image with the plugins. Create the Dockerfile in ~/tecnoshop-jenkins:

# TecnoShop Jenkins controller image
# Replace 2.xxx.y with the specific LTS version you have validated
FROM jenkins/jenkins:2.xxx.y-lts-jdk21

# Plugins with pinned versions
COPY --chown=jenkins:jenkins plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN jenkins-plugin-cli --plugin-file /usr/share/jenkins/ref/plugins.txt

Line by line:

  • FROM jenkins/jenkins:2.xxx.y-lts-jdk21: starts from the official image, with an exact LTS version (2.xxx.y is a placeholder: write the real number, which you will find in About Jenkins or in the list of tags on Docker Hub). That way, building the image today or a year from now gives you the same Jenkins.
  • COPY --chown=jenkins:jenkins plugins.txt /usr/share/jenkins/ref/plugins.txt: copies the plugin list into the image, owned by the jenkins user.
  • /usr/share/jenkins/ref/: the official image's reference directory. On startup, the container copies its contents to JENKINS_HOME according to some rules you will see later.
  • RUN jenkins-plugin-cli --plugin-file ...: the official plugin installation tool, included in the image. It downloads every plugin in the list and its dependencies, checks that they are compatible with the image's Jenkins version and leaves them in /usr/share/jenkins/ref/plugins. If something does not fit, it fails at build time, not when starting up in production.

plugins.txt: Pinned Versions

The format is one line per plugin: plugin-id:version. Comments with # are allowed.

# TecnoShop plugins.txt
# Generated from the Script Console; versions validated on jenkins-test
antisamy-markup-formatter:<version>
audit-trail:<version>
copyartifact:<version>
credentials-binding:<version>
git:<version>
github-branch-source:<version>
matrix-auth:<version>
nodejs:<version>
pipeline-graph-view:<version>
role-strategy:<version>
timestamper:<version>
workflow-aggregator:<version>
ws-cleanup:<version>
# ... remaining exported plugins and dependencies
  • The identifier is the plugin's ID (the one in its plugins.jenkins.io URL), not its display name: ws-cleanup is Workspace Cleanup and workflow-aggregator is the Pipeline plugin suite.
  • <version> stands for the exact number you will export from your installation.
Form Example Advantage Risk
Pinned version git:<version> Reproducible: always the same image You have to update the file deliberately
latest git:latest Always the latest at build time Two builds on different days produce different images; a breaking update slips in without warning
No version git Same as latest Same as latest

TecnoShop pins every version, including the dependencies: the exported list of the complete installation. To upgrade, jenkins-plugin-cli can tell you which new versions are available:

docker run --rm -v "$(pwd)/plugins.txt":/tmp/plugins.txt:ro \
  jenkins/jenkins:2.xxx.y-lts-jdk21 \
  jenkins-plugin-cli --plugin-file /tmp/plugins.txt --available-updates --output txt
  • Runs the tool in a temporary container of the target image, so that it computes the updates compatible with that Jenkins version.
  • --available-updates --output txt: prints the list with the available versions, in the same format. Review it, save it as the new plugins.txt and validate it in testing.

Exporting the List of Installed Plugins

From the Script Console

Manage Jenkins → Script Console:

Jenkins.instance.pluginManager.plugins
    .sort { it.shortName }
    .each { println "${it.shortName}:${it.version}" }
return
  • Jenkins.instance.pluginManager.plugins: the list of plugins loaded on the controller.
  • .sort { it.shortName }: sorts them by ID; a stable order keeps Git diffs readable.
  • println "${it.shortName}:${it.version}": prints each one in the plugins.txt format.
  • return: stops the console from also printing the value of the last expression.

Copy the output into ~/tecnoshop-jenkins/plugins.txt. Remember from 05-02 that the Script Console means full access: this script only reads, but it can read anything it wants.

With the REST API

curl -s -u "laura:$JENKINS_API_TOKEN" \
  "http://localhost:8080/pluginManager/api/json?depth=1&tree=plugins[shortName,version]" \
  | jq -r '.plugins[] | "\(.shortName):\(.version)"' | sort > plugins.txt
  • -u "laura:$JENKINS_API_TOKEN": authentication with an API token (no crumb is needed for a GET).
  • tree=plugins[shortName,version]: requests only those two fields.
  • jq -r ...: turns the JSON into id:version lines; sort sorts them.

The CLI offers the same thing with the list-plugins command; the API and the CLI are covered in 08-04.

Building and Using the Image with Docker Compose

The jenkins-controller service switches from image: to build::

services:
  jenkins-controller:
    build: .
    image: tecnoshop/jenkins-controller:2.xxx.y-1
    container_name: jenkins-controller
    restart: unless-stopped
    environment:
      PLUGINS_FORCE_UPGRADE: "true"
      TRY_UPGRADE_IF_NO_MARKER: "true"
    ports:
      - "8080:8080"
    volumes:
      - jenkins_home:/var/jenkins_home

  linux-agent-01:
    # ... unchanged from 05-01 ...
  • build: .: Compose builds the image with the Dockerfile in the current directory.
  • image: tecnoshop/jenkins-controller:2.xxx.y-1: with build and image together, Compose tags the built image with that name. TecnoShop's convention is <Jenkins version>-<own revision>: -1, -2... when only the plugins change. Previous images stay on your machine with their tags, and that is what will make rollback possible.
  • environment: the two variables are explained in the next section.
cd ~/tecnoshop-jenkins
docker compose build jenkins-controller
docker compose up -d jenkins-controller
docker compose logs -f jenkins-controller
docker image ls tecnoshop/jenkins-controller
  • docker compose build: builds the image (the first time, it downloads the base image and the plugins).
  • docker compose up -d: recreates the container with the new image; the volume is preserved.
  • docker image ls: lists the versions of the image you have built.

Keep Dockerfile, plugins.txt and docker-compose.yml under version control in a platform repository (with .env and backups/ in .gitignore). From now on, changing Jenkins means making a commit.

The Plugins Already in the Volume

There is a subtlety: the jenkins_home volume already has plugins installed by hand in the previous modules. On startup, the official image copies /usr/share/jenkins/ref/plugins to JENKINS_HOME/plugins with these rules:

State of the plugin in the volume Default behavior Variable that changes it
It does not exist The image's version is installed -
It came from the image and the image brings a newer version It is upgraded -
It was updated by hand from the interface The manual version is respected PLUGINS_FORCE_UPGRADE=true: it is upgraded if the image brings a newer version
It was installed by hand and never came from an image (no marker file) It is left as is TRY_UPGRADE_IF_NO_MARKER=true: it is upgraded if the image brings a newer version
  • The image records which version it installed in a marker file next to each plugin (<plugin>.jpi.version_from_image).
  • The image never uninstalls plugins: one that is in the volume but not in plugins.txt will stay there. To remove it, uninstall it from the interface and take it out of the list.
  • The image never downgrades a plugin that is newer in the volume.

TecnoShop enables both variables so that the image is the source of truth for plugins: the first time, it upgrades the ones installed by hand and, from then on, any update made from the interface in production will be corrected on the next startup if the image is newer. The team rule is simple: in production, nobody installs or updates plugins from the interface; you change plugins.txt.

TecnoShop's Safe Upgrade Procedure

flowchart TD
    A["Read the changelog,<br/>upgrade guide and advisories"] --> B["Branch in the platform repo:<br/>new FROM tag + plugins.txt"]
    B --> C["Build the candidate image"]
    C --> D["Restore the latest backup<br/>into jenkins_home_test"]
    D --> E["Start jenkins-test<br/>with the candidate"]
    E --> F{"Smoke test OK?"}
    F -->|"no"| B
    F -->|"yes"| G["Maintenance window:<br/>Prepare for Shutdown"]
    G --> H["Cold backup"]
    H --> I["Deploy the new image"]
    I --> J{"Verification OK?"}
    J -->|"yes"| K["Done: notify the team"]
    J -->|"no"| L["Rollback"]

  1. Prepare the Candidate

On a branch of the platform repository, Laura changes the FROM tag, updates plugins.txt with --available-updates and builds with a new tag, without touching the production one:

docker build -t tecnoshop/jenkins-controller:2.zzz.w-1 .

  1. The jenkins-test Environment

Add two services to docker-compose.yml that only start when the test profile is requested:

  jenkins-test:
    image: ${CANDIDATE_IMAGE:-tecnoshop/jenkins-controller:2.xxx.y-1}
    container_name: jenkins-test
    profiles: ["test"]
    environment:
      PLUGINS_FORCE_UPGRADE: "true"
      TRY_UPGRADE_IF_NO_MARKER: "true"
    ports:
      - "8091:8080"
    volumes:
      - jenkins_home_test:/var/jenkins_home

  test-agent:
    image: jenkins/inbound-agent:latest-jdk21
    container_name: test-agent
    profiles: ["test"]
    depends_on:
      - jenkins-test
    environment:
      JENKINS_URL: http://jenkins-test:8080/
      JENKINS_AGENT_NAME: linux-agent-01
      JENKINS_SECRET: ${LINUX_AGENT_01_SECRET}
      JENKINS_WEB_SOCKET: "true"

# and in the volumes block:
#   jenkins_home_test:
#     name: jenkins_home_test
  • profiles: ["test"]: a normal docker compose up -d does not start these services; only docker compose --profile test up -d does.
  • ${CANDIDATE_IMAGE:-...}: uses the CANDIDATE_IMAGE variable if it is set and, if not, the production tag.
  • test-agent connects only to jenkins-test, with the name and secret of linux-agent-01, which are valid in the copy because it shares the restored keys (you saw this in 05-03). That way the copy can run builds without touching the production agent. As long as TecnoShop's deployments are simulated there is no risk; once there are real deployments (module 7), the copy's jobs must not be able to reach the environments.

Restore the latest backup into the jenkins_home_test volume with the procedure from 05-03 (steps 1 and 2, changing the volume name) and start it:

CANDIDATE_IMAGE=tecnoshop/jenkins-controller:2.zzz.w-1 \
  docker compose --profile test up -d jenkins-test test-agent

At http://localhost:8091, change the Jenkins URL to that address.

  1. Smoke Test

Check Expected result
Startup log (docker compose logs jenkins-test) No SEVERE plugin loading errors
Manage Jenkins No warnings about plugins failing to load or unsatisfied dependencies
Manage Old Data Empty (if anything shows up, a plugin has changed or is missing)
About Jenkins The target version
linux-agent-01 in the copy Connected (it is test-agent)
orders-api build on main Green, with all its stages, tecnoshop-lib loaded and Smoke passing
catalog-web build on main Green, with all three matrix cells
A multibranch scan Reaches the private repository (credentials are correct)
Pipeline Graph View, consoles, artifacts Display correctly
Sign in as marta Same permissions as in production

When you are done: docker compose --profile test down (keep the test volume until next time, or delete it with docker volume rm jenkins_home_test).

  1. Maintenance Window

  1. Give advance notice in #ci-orders (for example, "Tuesday 07:30-08:00").
  2. Manage Jenkins → Prepare for Shutdown, with a message ("Jenkins upgrade, back at 08:00"). Jenkins enters quiet mode (quiet down): it does not start new builds, the ones in progress finish and new ones wait in the queue. It is the same action as /quietDown.
  3. Wait until Build Executor Status is empty.
  4. Cold backup: docker compose stop jenkins-controller and the backup from 05-03 (you can run backup-jenkins.sh, which does not need Jenkins to be running).
  5. Merge the platform repository branch and, in docker-compose.yml, change the tag to tecnoshop/jenkins-controller:2.zzz.w-1.
  6. docker compose up -d jenkins-controller (the image is already built; if not, run docker compose build first).
  7. Repeat the essential smoke test checks in production and run an orders-api build.
  8. Announce that you are done. Quiet mode goes away with the restart; if you call off the window without restarting, use Cancel Shutdown.

Rollback Plan

You need to have it written down before you start:

What failed Rollback
A specific plugin, detected after an update from the interface (for example, in testing) Manage Jenkins → Plugins → Installed plugins → Downgrade to <previous version>, available when Jenkins keeps the .bak copy of the previous version. Restart
A plugin, in the image Put it back to its previous version in plugins.txt and rebuild. Careful: the image does not downgrade what is already in the volume, so you will need the interface's Downgrade or the restore
The core or a set of plugins Go back to the previous tag in docker-compose.yml (tecnoshop/jenkins-controller:2.xxx.y-1, which is still on your machine) and restore the cold backup taken during the window. The restore is necessary because a new version may have converted configuration files to a format the previous one does not understand

The cold backup marks the point of no return: anything that happens in production after it (new builds) would be lost on restore. That is why verification is done immediately after upgrading, before reopening the service to the whole team.

Plugin Maintenance

Regular Updates

  • Security: as soon as an advisory affecting an installed plugin appears (05-02), prepare an image revision with only that change and follow the procedure, in an abbreviated form.
  • Functional: once a month, all available updates, validated on jenkins-test.
  • Do not fall months behind: the more versions you skip, the harder it is to work out what broke something.

Deprecated and Unmaintained Plugins

The Installed plugins tab and each plugin's page on plugins.jenkins.io show warnings:

Signal Meaning Action
Deprecated The project itself advises against the plugin; it usually points to the replacement Plan the migration and uninstall it
Up for adoption The plugin has no active maintainer Look for an alternative; if it is critical for you, consider contributing
No releases in years and unfixed security advisories Abandoned Replace or remove it

Uninstalling What Is Not Used

Every plugin costs controller memory, startup time and attack surface. Review the list quarterly (the Plugin Usage plugin helps you see which jobs use each one). Procedure, as in 02-06: disable first, observe for a few days, then uninstall and take it out of plugins.txt.

Dependencies and Conflicts

  • Plugins depend on one another. The interface does not let you uninstall a plugin that others depend on, and updating one may require newer versions of its dependencies.
  • A message such as Failed to load: ... Plugin is missing or Update required in Manage Jenkins indicates an unsatisfied dependency: that plugin does not load, and the jobs that use it fail.
  • jenkins-plugin-cli resolves dependencies when building the image and fails if it finds an incompatibility. That is one of the big advantages of the image: the conflict shows up on your machine, not in production.

General Installation Maintenance

Old Builds

  • Every TecnoShop pipeline has a buildDiscarder (03-04), and the multibranch jobs remove orphaned branches (04-05).
  • For jobs without their own policy, use Manage Jenkins → System → Global Build Discarders: add a Specific Build Discarder (for example, 30 days and 50 builds). It is applied periodically and after every build.

Orphaned Workspaces

  • Jenkins periodically deletes workspaces that have not been modified for more than 30 days, except the one on the node where each job's last build ran. When branches are removed from a multibranch job, their workspaces are deleted too.
  • What remains are the orphans of jobs that were deleted by hand or renamed. Check the agent from time to time with docker compose exec linux-agent-01 du -sh /home/jenkins/agent/workspace/* and delete the directories that do not correspond to any existing job.
  • The workspaces left by modules 1-4 on the built-in node (/var/jenkins_home/workspace) will never be used again: with the controller at 0 executors, you can delete them. The same goes for the /var/jenkins_home/.m2 cache.
docker compose exec jenkins-controller du -sh /var/jenkins_home/workspace /var/jenkins_home/.m2
docker compose exec jenkins-controller rm -rf /var/jenkins_home/workspace /var/jenkins_home/.m2
  • The first command shows how much space they take up; the second deletes them. Make sure beforehand that no job still builds on the built-in node.

Reindexing

After a restore or an update of the Git plugins, run Scan Multibranch Pipeline Now on orders-api and catalog-web so that Jenkins resynchronizes branches and PRs with GitHub.

Manage Old Data

Manage Jenkins → Manage Old Data lists data stored in the configuration that no installed plugin recognizes, usually because the plugin that created it was uninstalled or because its format changed. Review it: if it belongs to a plugin you removed on purpose, click Discard Unreadable Data; if not, you may be missing a plugin you still need.

Old Images on the Host

Keep at least the image prior to the production one (for rollback) and remove older ones with docker image rm tecnoshop/jenkins-controller:<tag>.

Maintenance Schedule

Frequency Task Reference
Daily (automatic) Encrypted backup 05-03
Weekly Review security warnings and node status 05-02, 05-01
Immediate Apply security fixes that affect the installation This lesson
Monthly Update plugins via jenkins-test; review Manage Old Data and disk space This lesson, 05-05
Every LTS (~12 weeks) Upgrade the core to the new baseline, usually once its .1 or .2 is out This lesson
Quarterly Restore drill; review unused, deprecated or unmaintained plugins; review roles, tokens and Script Approval signatures 05-03, 05-02
When upgrading the controller Review the agents' jenkins/inbound-agent tag 05-01

Common Mistakes and Tips

  • Using jenkins/jenkins:latest or lts in production: the next pull decides for you when to upgrade.
  • Updating every plugin at once in production from the interface: if something breaks, you will not know what caused it and you will not be able to reproduce it.
  • Skipping several baselines without reading the guide for each one: the changes that require action pile up.
  • Forgetting that the image does not uninstall or downgrade: a plugin removed from plugins.txt stays in the volume until you uninstall it.
  • Testing the upgrade on an empty Jenkins: it does not catch configuration migration problems. Always test on a real copy.
  • Deleting the previous image right after upgrading: it leaves you without a quick rollback.
  • Tip: in the platform repository's commit message, include a summary of the changelog you read and the result of the smoke test. It will become your Jenkins change history.

Exercises

Exercise 1. Migrate your environment to a custom image: export the plugin list from the Script Console, create Dockerfile and plugins.txt with the LTS version you are running right now (look it up in About Jenkins), switch the service to build: + image: and start it. How do you check that Jenkins is exactly the same version as before and that no plugin has changed?

Exercise 2. Someone has written git:latest in plugins.txt "so we don't have to maintain it". Explain in a review comment what problems this causes and what alternative you propose to stay up to date without losing reproducibility.

Exercise 3. After upgrading to 2.zzz.w-1, the catalog-web build fails because the NodeJS plugin does not load (unsatisfied dependency). It is 07:50 and the window ends at 08:00. Describe what you decide and the exact steps.

Solutions

Solution 1. Before the change, note the version shown in About Jenkins and save the plugin export as plugins-before.txt. After starting with the custom image, export again to plugins-after.txt and compare with diff plugins-before.txt plugins-after.txt: there should be no differences, and About Jenkins should show the same version. If FROM has a different version from the one you had, Jenkins will have been upgraded (or, worse, it will try to start an earlier version on top of your volume): fix the tag. docker image ls tecnoshop/jenkins-controller should show your 2.xxx.y-1 tag.

Solution 2. "latest makes the image depend on the day it is built: two builds of the same commit can end up with different plugins, a breaking version would reach production without going through jenkins-test, and we could not go back to the previous image with certainty. On top of that, jenkins-plugin-cli could resolve different dependencies from the ones we tested. Proposal: keep the versions pinned and, once a month, generate the new list with jenkins-plugin-cli --available-updates --output txt against the target image, validate it on jenkins-test and merge it through a PR. That way we stay up to date with the same effort, and we know what is changing."

Solution 3. With 10 minutes left and a failure affecting a project, the prudent decision is to roll back and analyze the problem calmly on jenkins-test (which, by the way, should have caught it: find out why it did not). Steps: (1) keep Prepare for Shutdown active so that no builds start; (2) docker compose stop jenkins-controller; (3) restore the window's cold backup into the jenkins_home volume (emptying the volume, or restoring into a new one and pointing the service at it); (4) go back to the tecnoshop/jenkins-controller:2.xxx.y-1 tag in docker-compose.yml; (5) docker compose up -d jenkins-controller; (6) verify orders-api and catalog-web; (7) announce in #ci-orders that the upgrade has been reverted and when it will be retried. Alternative, only if the diagnosis is immediate and certain: add the missing dependency version to plugins.txt, rebuild and deploy; but improvising in the last minute of a window is the classic way a small incident turns into a big one.

Conclusion

You now know how Jenkins publishes its releases (weekly, and LTS with a baseline every ~12 weeks and its .1, .2 and .3 releases), what to read before upgrading (changelog, LTS upgrade guide, security advisories and Java requirements) and why a moving tag is no good in production. TecnoShop has a reproducible custom image: a Dockerfile with a specific FROM jenkins/jenkins:2.xxx.y-lts-jdk21 and a plugins.txt with every version pinned, installed with jenkins-plugin-cli, built and tagged by Docker Compose, with PLUGINS_FORCE_UPGRADE and TRY_UPGRADE_IF_NO_MARKER so that the image has the final say over the plugins in the volume. Every upgrade follows the same path: candidate, backup restored into jenkins-test, smoke test, a window with Prepare for Shutdown, a cold backup and a rollback plan written in advance. And ongoing maintenance (deprecated or unmaintained plugins, dependencies, old builds and workspaces, Manage Old Data) has a schedule. What is still missing is knowing whether Jenkins is healthy without waiting for someone to complain: whether the queue is growing, the disk is filling up or memory is running out. That is what you will see in Monitoring Jenkins.

© Copyright 2026. All rights reserved