I do not want to allow two jobs of the same type (same repository) to run in parallel on the same node.
How can I do this using groovy inside Jenkinsfile ?
The answer provided in https://stackoverflow.com/a/43963315/6839445 is deprecated.
The current method to disable concurrent builds is to set options:
options { disableConcurrentBuilds() }
Detailed description is available here: https://jenkins.io/doc/book/pipeline/syntax/#options