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.
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.
pipeline {
agent any
environment { IMAGE_TAG = "build-${env.BUILD_NUMBER}" }
stages {
stage('Deploy') {
steps { echo "Deploying ${env.IMAGE_TAG}" }
}
}
}Guard optional values
- Confirm the variable is actually set on the path that reaches the failing line.
- For optional env vars, default them:
env.FOO ?: 'fallback'. - Declare shared
defvariables at pipeline scope (or useenv) so later stages can read them.
How to prevent it
- Define cross-stage values in
environment {}or setenv.X, not block-localdef. - Reference params/env explicitly via
params.andenv.prefixes. - Lint the Jenkinsfile and run it on a branch before relying on new variables.