How to get the pipeline configuration field 'Script Path' when executing the Jenkinsfile?
问题 How can I get the content of the pipeline configuration field 'Script Path' in Jenkins from the Jenkinsfile (groovy)? In this example: I want to get the string 'Apps/mq-logger/Jenkinsfile' when executing the Jenkinsfile itself. 回答1: You can get a script path this way def scriptPath = currentBuild.rawBuild.parent.definition.scriptPath Note that you have to approve all these methods. 回答2: If you want this string to be customizable during the build time, you can create a parameterized build as