jugal jugal - 9 days ago 5
Git Question

Get the project which has been modified in a git repository

so i m trying to create a pipeline for continuous delivery in Jenkins. My first step is to import the git repository to my Jenkins server. To give an idea my git repository is hosted on a bitbucket server ( for eg testrepository.git). Now within this repository the structure is as follows

Testrepository.git


  • project 1

  • project 2

  • project 3



My aim is to get the list of projects which have been modified and build only those in my pipeline. Is there a way to achieve this ? All the projects are java projects with gradle build file

gzh gzh
Answer

git log --name-only will show you the filename list modified in each commit. you can analyse filename list to judge which project was modified.

If you do continuous delivery, you can get modified file list from last delivery by the following command, suppose "2016-11-10 16:00" is your last delivery timestamp.

git diff $(git rev-list -n 1 --before="2016-11-10 16:00" HEAD) --name-only