A declarative pipeline must be defined within a pipeline directive that includes an agent directive; for scripted pipelines, the Pipeline must be enclosed within the node directive.
The node directive in a Scripted Pipeline is similar to the agent directive in the Declarative Pipeline, and allocates an executor and workspace for the pipeline. Unlike the agent directive, the node will not automatically download the source repository and save it to your workspace; instead, you have to specify that manually using the checkout scm step:
node { checkout scm}