In a Jenkins Pipeline, $class is a special map key that tells Jenkins which plugin or core class to create when a step or property accepts more than one possible implementation, as in checkout([$class: 'GitSCM', ...]). This page explains how $class works, when you still need it, how it maps to the shorter symbol syntax, and how to fix the errors it most often causes.
In Jenkins pipeline scripts, the $class parameter is used to specify the class or type of an object. The complete list of $class values depends on the specific plugins and extensions installed in your Jenkins instance. Each plugin or extension may introduce its own set of classes that can be used in the pipeline script.
However, here are some common $class values that are frequently used in Jenkins pipeline scripts:
'ChoiceParameter': Represents a parameter with a choice or selection.'CascadeChoiceParameter': Represents a parameter with cascading choices or selections.'GroovyScript': Represents a script block containing Groovy code.'StringParameterDefinition': Represents a parameter for accepting a string value.'BooleanParameterDefinition': Represents a parameter for accepting a boolean value.'RunParameterDefinition': Represents a parameter for selecting a specific Jenkins run or build.'FileParameterDefinition': Represents a parameter for accepting a file as input.'TextParameterDefinition': Represents a parameter for accepting multiline text as input.'PasswordParameterDefinition': Represents a parameter for accepting a password or sensitive information.
These are just a few examples, and the available $class values can vary depending on the plugins and extensions installed in your Jenkins environment. It’s recommended to refer to the documentation of the specific plugins you are using to determine the supported $class values and their configurations.
What $class actually does
Many Pipeline steps take an argument whose type is an *extension point*: an abstract type that several plugins can implement. checkout accepts any SCM (Git, Subversion and others), properties accepts any job property, and parameters accepts any parameter definition. When you pass a Groovy map for one of these arguments, Jenkins needs to know which concrete class to build, and the $class key tells it. Every other key in the map is passed to that class's @DataBoundConstructor arguments or @DataBoundSetter properties.
// $class picks the implementation; the other keys configure it
checkout([
$class: 'GitSCM',
branches: [[name: '*/main']],
userRemoteConfigs: [[url: 'https://github.com/example/app.git']],
extensions: [[$class: 'CleanBeforeCheckout']]
])Code language: PHP (php)
The value is usually the simple class name, such as GitSCM. If two installed plugins define classes with the same simple name, use the fully qualified name instead, for example $class: 'hudson.plugins.git.GitSCM'. The Structs plugin, which every Pipeline installation depends on, does this conversion.
Note: $class is not limited to scripted Pipeline. It works the same way in Declarative Pipeline, for example inside steps { checkout([$class: 'GitSCM', ...]) } or in a script block.
$class versus symbols
Plugin authors can add a @Symbol annotation to their classes. When a class has a symbol, you can call it like a function instead of writing a $class map. Symbols are shorter and easier to read, and the Snippet Generator produces them today. The $class form is still useful when a plugin has no symbol. This is common for older plugins and for nested objects such as Git extensions.
// $class form
properties([
[$class: 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '10']],
[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
[$class: 'StringParameterDefinition', name: 'VERSION',
defaultValue: '1.0.0', description: 'Release version'],
[$class: 'BooleanParameterDefinition', name: 'RUN_TESTS',
defaultValue: true, description: 'Run the test stage']
]]
])
// Equivalent symbol form (preferred when available)
properties([
buildDiscarder(logRotator(numToKeepStr: '10')),
parameters([
string(name: 'VERSION', defaultValue: '1.0.0', description: 'Release version'),
booleanParam(name: 'RUN_TESTS', defaultValue: true, description: 'Run the test stage')
])
])Code language: PHP (php)
Both blocks produce the same job configuration. The table below lists each class from the post above with its symbol and the plugin that provides it.
| $class value | Symbol | Provided by | Notes |
|---|---|---|---|
StringParameterDefinition | string | Jenkins core | Single-line text |
TextParameterDefinition | text | Jenkins core | Multi-line text |
BooleanParameterDefinition | booleanParam | Jenkins core | Checkbox; value is a real boolean in params |
ChoiceParameterDefinition | choice | Jenkins core | Static drop-down list |
PasswordParameterDefinition | password | Jenkins core | Masked input; prefer credentials for real secrets |
RunParameterDefinition | run | Jenkins core | Selects a build of another job |
FileParameterDefinition | none usable | Jenkins core | Not supported in Pipeline jobs; see corrections |
ChoiceParameter | check Snippet Generator | Active Choices plugin | Drop-down filled by a Groovy script |
CascadeChoiceParameter | check Snippet Generator | Active Choices plugin | Choices that react to other parameters |
GroovyScript | none | Active Choices plugin | Script model used inside Active Choices parameters |
Corrections to the list above
$classis not a parameter. It is a reserved map key that selects the class Jenkins should create from that map.ChoiceParameter,CascadeChoiceParameterandGroovyScriptare not built in. They come from the Active Choices plugin, and they fail with an unknown-implementation error if that plugin is not installed. The core static choice parameter isChoiceParameterDefinition(symbolchoice).GroovyScriptis not a general script block. It is the Active Choices object that holds the script, plus a fallback script, used to generate parameter values.FileParameterDefinitiondoes not work in Pipeline jobs because the uploaded file never reaches the workspace. Use the File Parameters plugin instead, which providesbase64FileandstashedFile.- Most of the core
*ParameterDefinitionclasses have symbols (string,text,booleanParamand so on). Symbols are the recommended syntax in current Pipeline code.
Example: Active Choices parameters with $class
Active Choices is where you still see $class most often, because most published examples use the map form. The scripted Pipeline below defines an environment drop-down and a region drop-down whose options change based on the selected environment. It requires the Active Choices plugin.
properties([
parameters([
[$class: 'ChoiceParameter',
name: 'ENVIRONMENT',
description: 'Target environment',
choiceType: 'PT_SINGLE_SELECT',
filterable: false,
script: [$class: 'GroovyScript',
script: [classpath: [], sandbox: true,
script: 'return ["dev", "staging", "prod"]'],
fallbackScript: [classpath: [], sandbox: true,
script: 'return ["error"]']
]
],
[$class: 'CascadeChoiceParameter',
name: 'REGION',
description: 'Region for the selected environment',
choiceType: 'PT_SINGLE_SELECT',
referencedParameters: 'ENVIRONMENT',
filterable: false,
script: [$class: 'GroovyScript',
script: [classpath: [], sandbox: true, script: '''
if (ENVIRONMENT == "prod") { return ["us-east-1", "eu-west-1"] }
return ["us-east-1"]
'''],
fallbackScript: [classpath: [], sandbox: true,
script: 'return ["error"]']
]
]
])
])
node {
stage('Deploy') {
echo "Deploying to ${params.ENVIRONMENT} in ${params.REGION}"
}
}Code language: PHP (php)
choiceTypecontrols the widget:PT_SINGLE_SELECT,PT_MULTI_SELECT,PT_RADIOorPT_CHECKBOX.referencedParameterslists the parameters whose values are passed into the cascade script as variables. Separate multiple names with commas.fallbackScriptruns if the main script throws an error, so the form still renders.- The inner
scriptmaps are Script Security sandbox scripts. If a script calls methods the sandbox does not allow, an administrator must approve them under Manage Jenkins > In-process Script Approval.
Note: Parameters defined with properties only appear after the Pipeline has run once. Run the job once (it uses default or empty values). After that, Build with Parameters shows the new form.
Other places you will see $class
Outside parameters, $class appears mostly in older Pipelines and in steps that wrap freestyle build features. The comment on each line shows the modern equivalent.
step([$class: 'ArtifactArchiver', artifacts: 'target/*.jar']) // archiveArtifacts 'target/*.jar'
step([$class: 'JUnitResultArchiver', testResults: '**/TEST-*.xml']) // junit '**/TEST-*.xml'
wrap([$class: 'TimestamperBuildWrapper']) { sh 'make' } // timestamps { sh 'make' }
checkout([$class: 'GitSCM', branches: [[name: '*/main']],
userRemoteConfigs: [[url: 'https://github.com/example/app.git']]])
// git url: '...', branch: 'main'Code language: PHP (php)
How to find the right $class value and keys
- Open any Pipeline job and click Pipeline Syntax, or go to
JENKINS_URL/job/<job-name>/pipeline-syntax. - In the Snippet Generator, choose a step such as
properties,checkoutorstep, fill in the form, and click Generate Pipeline Script. The output uses a symbol where one exists and falls back to$classwhere it does not. - For Declarative
options,parametersandtriggers, use the Declarative Directive Generator on the same page. - Look up the class's
@DataBoundConstructorand@DataBoundSetterfields in the plugin's documentation or source. The map accepts only these keys.
Note: Write the key as $class: (unquoted) or '$class': (single quotes). Do not use double quotes: "$class" is a Groovy GString, so Groovy tries to substitute a variable named class.
Common errors and fixes
| Symptom | Cause | Fix |
|---|---|---|
Error saying there is no known implementation of a type named X | The plugin that provides X is not installed, or the name is misspelled | Install the plugin (for example Active Choices) or correct the class name |
| Error about an ambiguous class name | Two plugins define a class with the same simple name | Use the fully qualified class name in $class |
| Warning about unknown parameters for a class, and the setting is ignored | A map key does not match any constructor argument or setter | Regenerate the snippet with the Snippet Generator and copy the exact key names |
| Parameters do not appear in the UI | The properties step has not run yet | Run the job once, then use Build with Parameters |
| Settings made in the job UI disappear | properties replaces the job's properties on every run | Define all job properties in the Jenkinsfile, not partly in the UI |
Best practices
- Use symbols when they exist. Keep
$classfor classes that have no symbol. - Keep job properties and parameters in the Jenkinsfile so they are versioned and reviewed along with the pipeline.
- Do not collect real secrets through password parameters. Store them as Jenkins credentials and read them with
withCredentials. - Test plugin upgrades before rolling them out. Class names and fields belong to plugins, so a major plugin release can rename or remove them.
- For more Pipeline syntax, see the Jenkins Pipeline Complete Reference Tutorials.
Frequently asked questions
What does $class mean in a Jenkinsfile?
It is a special map key that names the concrete class Jenkins should create when a step or property accepts several possible implementations. The other keys in the map configure that class.
Should I use $class or the symbol syntax?
Use the symbol syntax, such as string(...) or buildDiscarder(logRotator(...)), whenever the plugin provides one, because it is shorter and easier to read. Use $class only for classes without a symbol.
Does $class work in Declarative Pipeline?
Yes. Scripted and Declarative Pipelines use the same conversion, so $class maps work inside steps, inside script blocks and as step arguments in either style.
Why do I get a 'no known implementation' error with $class?
Either the class name is wrong or the plugin that provides it is not installed. Check the spelling, install the plugin, or use the fully qualified class name if the simple name is ambiguous.
Where do ChoiceParameter and CascadeChoiceParameter come from?
They come from the Active Choices plugin, not Jenkins core. The core static drop-down is ChoiceParameterDefinition, available as the choice symbol.
Related tutorials
- Jenkins Pipeline Complete Reference Tutorials
- Environment variables and properties defined in jenkins | Jenkins Tutorial
- Top 50 Jenkin pipeline interview questions and answers
- More Jenkins tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals