Agile and Scrum

How do I configure a Jenkins pipeline to locate and run a Jenkinsfile from a specific subfolder?

KI Asked by Kimberly Taylor · 15-09-2025
0 upvotes 9,081 views 0 comments
The question

I am currently reorganizing our project repository to follow a cleaner structure, and I've moved my Jenkinsfile into a dedicated '/deploy/pipeline/' directory instead of keeping it in the root folder. However, my multi-branch pipeline job is now failing because it can't find the definition file. Is there a setting in the Jenkins UI or a specific parameter in the SCM configuration that allows me to point Jenkins to a custom path for the Jenkinsfile? I want to ensure my Agile team can maintain separate build scripts without cluttering the main source code root.

3 answers

0
SA
Answered on 18-09-2025

To run a Jenkinsfile from a specific folder, you need to adjust the Script Path in your Jenkins job configuration. Navigate to your Pipeline job, go to the 'Configure' section, and scroll down to the 'Pipeline' definition. If you are using 'Pipeline script from SCM', you will see a field labeled Script Path. By default, it is set to Jenkinsfile. You simply need to change this to the relative path of your file, for example: deploy/pipeline/Jenkinsfile. Once saved, Jenkins will look specifically in that directory during the "Declaration Checkout" phase. This is a standard practice in complex software development environments where you might have multiple pipelines for different environments stored in the same repository.

0
MI
Answered on 20-09-2025

Are you using a standard Pipeline job or a Multi-branch Pipeline, and are you worried about how this change might affect the auto-discovery of branches across your Agile project?

DA 22-09-2025

That is a great point, Michael. For Multi-branch pipelines, the configuration is slightly different but follows the same logic. You have to go into the 'Build Configuration' section of the multi-branch setup and update the 'Script Path' there. If you don't, Jenkins won't recognize any branch as having a valid pipeline, and your build history will disappear. It's also worth noting that the path is always relative to the root of the repository, so don't start the path with a forward slash.

0
BA
Answered on 10-10-2025

You can also use the 'Remote Loader' plugin if you need to pull a Jenkinsfile from an entirely different repository, but for a subfolder, the Script Path setting is definitely the easiest way.

KI 12-10-2025

I agree with Barbara. For most users, just updating the Script Path in the SCM settings is the cleanest solution. It keeps everything native to the Jenkins core without needing extra plugins.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session