Chapter 05Lesson 04~105 minutes

Freestyle Projects, Build Steps, Post-Build Actions, Parameters, Triggers, and Legacy Job Maintenance: Diagnostics, Failure Modes, Security, and Performance

Diagnose Freestyle failures by preserving configuration and build evidence before fixing drift, unsafe parameters, overlapping timers, workspace residue, or missing plugin behavior.

DiagnosticsConfiguration driftWorkspace hygienePlugin riskPerformance

Learning objectives

  • Apply an evidence-first diagnostic sequence across job configuration, queue, agent, workspace, build step, publisher, and external target layers.
  • Diagnose configuration drift when controller-side UI changes have no SCM history.
  • Prevent unsafe parameter handling and overlapping timer runs from becoming destructive side effects.
  • Reproduce workspace-residue failures without erasing the evidence that caused them.
  • Handle missing or incompatible legacy plugin behavior through isolated testing rather than blind reinstall or upgrade.

1. Diagnose the layer, not the symptom

A failing legacy job invites destructive shortcuts: rerun until green, delete the workspace, reinstall a plugin, or rewrite the job from memory. Those actions often remove the evidence that would identify the real layer. Preserve the job full name, build and queue IDs, cause, parameters, console log, agent, workspace path, artifact list, configuration snapshot, and plugin baseline first.

Evidence-first diagnostic path
flowchart TD
 A[Preserve build + config evidence] --> B[Controller/core/plugin baseline]
 B --> C[Job config + cause + parameters]
 C --> D[Queue + label + executor]
 D --> E[Agent + workspace + tools]
 E --> F[Build step exit/status]
 F --> G[Publisher / artifact / report]
 G --> H[External side effect]
 H --> I[Smallest reversible fix]
 I --> J[Targeted rerun + compare]

2. Failure mode: configuration drift with no SCM history

Two builds may differ because someone changed a parameter default, label, shell command, trigger, or publisher between them. Jenkins build history alone does not necessarily preserve a complete historical copy of every prior job configuration.

Response: capture current config.xml, compare it with your last reviewed snapshot, identify the exact changed field, and document who/what owns the configuration source. Do not “fix” drift by copying XML from another controller without understanding plugin and version differences.

3. Failure mode: dangerous or malformed parameter values

A Freestyle string parameter may become an environment variable consumed by a shell, batch file, package tool, or deployment command. A value such as a path or command fragment can therefore alter behavior unexpectedly if the script trusts it.

Unsafe pattern: constructing a shell command from a free-form parameter and evaluating it. Prefer a closed set of allowed values and pass data as quoted arguments or environment variables to code that validates it.
case "$TARGET_ENV" in
  dev|test) ;;
  *) printf 'Rejected target: %s\n' "$TARGET_ENV" >&2; exit 2 ;;
esac

Preserve the rejected parameter value in a redacted evidence record if it is not sensitive. Do not log secrets merely to make diagnosis easier.

4. Failure mode: overlapping scheduled runs

A timer can queue a new build while an earlier build is still running. If both write the same external location or compete for a shared database, “more executors” can make the incident worse by increasing overlap.

First inspect queue wait, start/end times, causes, and resource collisions. Then choose a control appropriate to the actual risk: disable concurrent builds for the job, move the shared resource behind an explicit lock, reduce schedule frequency, or redesign the workflow. Jenkins also recommends hashed schedules such as H to avoid synchronized load spikes.

5. Failure mode: relying on workspace leftovers

Suppose build 17 succeeds because out/package.zip was left by build 16, even though the current build step no longer produces it. The archive publisher can retain stale bytes and create a false green signal.

Reproduce the job in a clean workspace or explicitly remove the output directory at the start. Record the artifact digest before and after. The correct fix is to make the producer deterministic, not to preserve stale files because they keep the publisher green.

6. Failure mode: plugin removal breaks a legacy publisher

A job can contain configuration contributed by a plugin that is no longer installed or compatible. Symptoms may include missing UI sections, warnings about unreadable data, configuration loss, or a build that no longer performs a post-build action.

  1. Do not reinstall or upgrade blindly on the production controller.
  2. Preserve the affected job XML, plugin inventory, controller version, and logs.
  3. Identify the plugin ID/version that previously owned the configuration.
  4. Check current maintenance/security/compatibility information.
  5. Test restoration or migration on an isolated clone.
  6. Only then choose reinstall, upgrade, replacement, or behavior migration.

7. Intentionally broken example: stale artifact succeeds

Consider a disposable job whose first build creates out/result.txt, while the second build changes the script so it skips file creation but leaves the workspace intact. If the archive publisher still finds the old file, the second build may appear to have produced evidence it did not create.

Diagnosis:

  • compare console output for both build numbers;
  • compare artifact digests and timestamps;
  • inspect the agent workspace path;
  • clean out/ and rerun only the second build;
  • confirm the archive now fails or is empty, exposing the real producer defect.

Repair the producer so it creates the intended artifact each run, then keep the clean-output step. Do not hide the failure by allowing an empty archive unless emptiness is genuinely valid behavior.

8. A green Freestyle build has a narrow meaning

Even after all build steps and publishers succeed, an external service may reject or later invalidate a side effect. A mail publisher can enqueue a message while delivery fails later; a package upload can return success while consumers fetch a different mutable version. Separate Jenkins result from provider-side evidence.

9. Performance: measure queue and execution separately

A “slow job” might spend most of its time waiting for an eligible agent rather than executing. Record queue-enter time, executor start, build duration, node label, workspace I/O, artifact size, and publisher latency before adding executors or parallelism.

For legacy controllers, large artifacts and long console logs also consume controller storage and UI/API resources. Retention policy is therefore part of performance and recovery design, not cosmetic housekeeping.

10. Smallest-fix checklist

  • Preserve first-failure evidence before restart, cleanup, plugin change, or rerun.
  • Confirm the job configuration and trigger cause that produced the run.
  • Confirm queue/label/executor state before blaming the script.
  • Confirm the exact agent/workspace/toolchain.
  • Inspect each build step and each publisher independently.
  • Validate external side effects outside Jenkins.
  • Change one causal hypothesis at a time and compare the new run against preserved evidence.
Next lesson

Checkpoint Lab — Freestyle Projects and Legacy Job Maintenance

Build a complete disposable Freestyle job, prove allowed behavior and retained evidence, then produce a migration plan that preserves function while reducing hidden controller-side state.

Knowledge check

Why should you preserve config.xml before changing a failing legacy job?

A scheduled job overlaps with itself. Is adding executors the first fix?

Why can a stale workspace create a false green build?

A publisher disappears after a plugin change. What should you do first?

What does a successful Jenkins build not necessarily prove?

Official references and version notes

Version and compatibility note

Rechecked on 2026-09-15. The current Jenkins LTS baseline used by this chapter is 2.568.3, tested on Java 21 and 25. Mandatory labs assume Java 21 and use only core Freestyle/parameter/timer/artifact capabilities unless your controller already requires additional dependencies. Builds must execute on a disposable agent rather than the built-in node. If a future Jenkins LTS or plugin baseline differs, revalidate behavior before copying these exact steps.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.