jenkinsci/jenkins · error · IllegalArgumentException

Not sure what you meant by "%s".

Error message

Not sure what you meant by "%s".

What it means

In `ConsoleCommand.run()`, when BUILD is non-numeric AND is not a known permalink AND `job.getPermalinks().findNearest(build)` returns null (no close match), IllegalArgumentException 'Not sure what you meant by "<build>".' is thrown (chained with the NumberFormatException). The BUILD argument is entirely unrecognizable.

Source

Thrown at core/src/main/java/hudson/cli/ConsoleCommand.java:62

        job.checkPermission(Item.READ);

        Run<?, ?> run;

        try {
            int n = Integer.parseInt(build);
            run = job.getBuildByNumber(n);
            if (run == null)
                throw new IllegalArgumentException("No such build #" + n);
        } catch (NumberFormatException e) {
            // maybe a permalink?
            Permalink p = job.getPermalinks().get(build);
            if (p != null) {
                run = p.resolve(job);
                if (run == null)
                    throw new IllegalStateException("Permalink " + build + " produced no build", e);
            } else {
                Permalink nearest = job.getPermalinks().findNearest(build);
                throw new IllegalArgumentException(nearest == null ?
                        String.format("Not sure what you meant by \"%s\".", build) :
                        String.format("Not sure what you meant by \"%s\". Did you mean \"%s\"?",
                                build, nearest.getId()), e);
            }
        }

        OutputStreamWriter w = new OutputStreamWriter(stdout, getClientCharset());
        try {
            long pos = n >= 0 ? seek(run) : 0;

            if (follow) {
                AnnotatedLargeText logText;
                do {
                    logText = run.getLogText();
                    pos = logText.writeLogTo(pos, w);
                    // TODO should sleep as in Run.writeWholeLogTo
                } while (!logText.isComplete());
            } else {

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Pass a valid integer build number or a built-in permalink: lastBuild, lastStableBuild, lastSuccessfulBuild, lastFailedBuild.
  2. Omit the BUILD argument entirely to default to lastBuild.
  3. Inspect `job.getPermalinks()` (or the job's permalink action) to see which permalink IDs are valid for this job.

Example fix

// before: unrecognized token
//   java -jar jenkins-cli.jar console myjob foo
//   -> IllegalArgumentException: Not sure what you meant by "foo".
//
// after: use a valid build number or permalink
//   java -jar jenkins-cli.jar console myjob lastBuild
Defensive patterns

Strategy: validation

Validate before calling

// Accept only a number or a registered permalink ID before calling the CLI/console API
boolean isNumber = buildArg.matches("\\d+");
boolean isPermalink = job.getPermalinks().stream()
        .anyMatch(pl -> pl.getId().equals(buildArg));
if (!isNumber && !isPermalink) {
    throw new IllegalArgumentException(
        "BUILD must be a number or one of: "
          + job.getPermalinks().stream().map(Permalink::getId).collect(joining(", ")));
}

Prevention

When it happens

Trigger: Running `java -jar jenkins-cli.jar console <job> <token>` where token is neither a number, nor a registered permalink, nor close enough to one to suggest — e.g. a random string like 'foo'.

Common situations: Passing a garbage value, wrong field, or a permalink name from a plugin that isn't registered on this job.

Related errors


AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14). Data as JSON: /api/errors/e34b738f7bc309b2. Report an issue: GitHub.