I'm currently trying to get the following work. There is a git repository which contains lot's of directories. Now my Jenkins pipeline only should be triggered if a file inside 1 specific directory of that repository changes.
I tried a lot until yet but couldn't find a solid solution. The only way how I got to work is:
- Sub file changes
- Pipeline will be triggered
- Pipeline checks that sub directory has no checks
- Pipeline skipps all other steps and finishes with success. (Have skipping enabled)
But this isn't satisfying as everytime somebody merges into master of that repository the pipeline will be triggered but I want to get it triggered if something changes inside the sub directory only.
This is my configuation:
stage('Checkout directory') {
checkout([
$class: 'GitSCM',
branches: [[name: 'master']],
extensions: [[$class: 'SparseCheckoutPaths', sparseCheckoutPaths:[[$class: 'SparseCheckoutPath', path: '<sub-directory-of-repo>/']]]],
userRemoteConfigs: [[url: 'git@github.com:<my-org>/<org-repo>.git']]
])
}
How do I need to extend the configuration to only hook the trigger if something inside <sub-directory-of-repo>/
changes?