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 ?
You got at the disableConcurrentBuilds property:
properties properties: [ ... disableConcurrentBuilds(), ... ]
Then the job would wait the older one to finish first