Interview Prep/Jenkins/Declarative pipeline syntax

What agent types exist in declarative pipelines?

IntermediateConceptDeclarative pipeline syntax
Answer
Type Meaning
agent any Any available executor
agent none No global agent; each stage declares its own
agent { label 'linux && docker' } Node matching the expression
agent { node { label 'linux'; customWorkspace '/data/ws/app' } } Label plus options
agent { docker { image 'maven:3.9-eclipse-temurin-21'; args '-v m2:/root/.m2' } } Run steps inside a container on a Docker-capable node
agent { dockerfile { filename 'ci/Dockerfile' } } Build and use an image from the repo
agent { kubernetes { yamlFile 'ci/pod.yaml'; defaultContainer 'maven' } } Pod via the kubernetes plugin
All Jenkins questions Roadmap: Jenkins

More on Declarative pipeline syntax