I'm trying to create a cronjob to backup all my Jenkins configuration in git. The only thing I need to be tracked in my repository is the config.xml
in every Jenkins project. The file system is structured like ../jenkins/jobs/[PROJECTNAME]/config.xml
. The .git
is located in jobs.
I don't want to explicitly ignore all other folder/files, but allow only the config.xml
in that location. I came up with the following working solution:
*
!.gitignore
!config.xml
!*/
*/workspace
*/modules
/config-history
*/config-history
*/*/config-history
*/*/*/config-history
*/*/*/*/config-history
*/*/*/*/*/config-history
*/*/*/*/*/*/config-history
*/*/*/*/*/*/*/config-history
Unfortunate there are many projects and the git add .
takes a while. Ignore workspace
, the directly with most files in, didn't add any benefit.
Btw. the intuitive and short way didn't work at all:
*
!.gitignore
!*/config.xml
Any ideas to either optimize my .gitignore or my git add without listing all files in either case?