Skip to content
Latchkey

Jenkins "MissingPropertyException: No such property" in Pipeline

Groovy tried to read a property or variable that does not exist in the current scope. In a Jenkinsfile this is almost always an undefined variable, a misspelled env name, or a value referenced outside the block where it was defined.

What this error means

A stage fails with groovy.lang.MissingPropertyException: No such property: <name> for class: WorkflowScript (or Script1). The pipeline ran until it dereferenced the missing name.

Jenkins console
groovy.lang.MissingPropertyException: No such property: IMAGE_TAG for class: WorkflowScript
	at WorkflowScript.run(WorkflowScript:27)

Common causes

Variable used before it was defined or out of scope

A def x declared inside one block is not visible in another. Reading it elsewhere - or relying on a variable a previous, skipped stage was supposed to set - yields no such property.

Misspelled or unset environment variable

Referencing env.IMAGE_TAG (or bare IMAGE_TAG) when nothing set it, or a typo in the name, resolves to a missing property rather than an empty string.

Declarative directive read like a property

Treating a parameter or credential as a top-level property without going through params.X / env.X can miss the binding and raise this error.

How to fix it

Reference variables through the right binding

Use env.NAME for environment, params.NAME for parameters, and keep def variables in a scope visible where you read them.

Jenkinsfile
pipeline {
  agent any
  environment { IMAGE_TAG = "build-${env.BUILD_NUMBER}" }
  stages {
    stage('Deploy') {
      steps { echo "Deploying ${env.IMAGE_TAG}" }
    }
  }
}

Guard optional values

  1. Confirm the variable is actually set on the path that reaches the failing line.
  2. For optional env vars, default them: env.FOO ?: 'fallback'.
  3. Declare shared def variables at pipeline scope (or use env) so later stages can read them.

How to prevent it

  • Define cross-stage values in environment {} or set env.X, not block-local def.
  • Reference params/env explicitly via params. and env. prefixes.
  • Lint the Jenkinsfile and run it on a branch before relying on new variables.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →