Pipeline scoped to its subdirectory/branch in a (mono)repo

What if any is Jenkins’ equivalent to the following GitHub Actions featureset.

When using the push and pull_request events, you can configure a pipeline/workflow to run based on what file paths are changed. Path filters are not evaluated for pushes of tags.

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore

When using the pull_request and pull_request_target events, you can configure a pipeline/workflow to run only for pull requests that target specific branches.

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpull_requestpull_request_targetbranchesbranches-ignore

Looks like the closest equivalent I can find is following which is available not available for scripted pipeline.

changeset

Execute the stage if the build’s SCM changeset contains one or more files matching the given pattern. Example: when { changeset "**/*.js" }

The optional parameter comparator may be added after an attribute to specify how any patterns are evaluated for a match: EQUALS for a simple string comparison, GLOB (the default) for an ANT style path glob case insensitive, this can be turned off with the caseSensitive parameter, or REGEXP for regular expression matching. For example: when { changeset pattern: ".TEST\\.java", comparator: "REGEXP" } or when { changeset pattern: " */*TEST.java", caseSensitive: true }

You did not really ask a question, are you looking for guidance how to implement when { changset } with scripted Pipeline?

Is there a specific reason you are looking for scripted pipeline?
Note you can use the script{} esacpe-hatch in many places in declarative Pipeline.

Thanks much for responding. Well, is there a native solution for jenkins users who are invested in scripted pipeline (see reasons below) and do not plan to migrate to the declarative pipeline.

“Jenkins has long shipped with an embedded Groovy engine to provide advanced scripting capabilities for admins and users alike. The Groovy learning-curve isn’t typically desirable for all members of a given team, so Declarative Pipeline was created to offer a simpler and more opinionated syntax for authoring Jenkins Pipeline.
:
As it is a fully-featured programming environment, Scripted Pipeline offers a tremendous amount of flexibility and extensibility to Jenkins users. Both are fundamentally the same Pipeline sub-system underneath.”

Scripted Pipeline currently has no built-in when step, but you can hook into the API the declarative Pipeline is using, see jenkins - Jenkinsfile - Conditional stage execution in the Script Pipeline syntax - Stack Overflow.

Per the comments on JENKINS-47286, it doesn’t sound like adding when support to Scripted Pipeline will happen. As a potential workaround, there is a shared library implementing the when statement for scripted pipelines: github: comquent/imperative-when

The when { changeset } you can emulate using git CLI and GIT_PREVIOUS_(SUCCESSFUL_)COMMIT.

Thanks very much for your help. Much appreciated.