Skip to content

Commit 9c66f19

Browse files
committed
Improved JENKINS_HOME example
After years of use I've come up with some improvements to the `JENKINS_HOME.gitignore` example. - Major performance improvement: On very large Jenkins installations that have been running for more than one year, there tends to be many builds (hundreds of thousands of builds). The `builds` directory of these jobs contain millions of files which would cause Git to hang for several minutes on simple commands like `git status` and longer for committing changes. `strace` was used on Git to figure out the performance impact and this proposed change includes the optimization. I also added a clear comment explaining the line's purpose. - There's an example for how to include Jenkins encryption keys, and there's a disclaimer informing the user why they shouldn't but still giving an example. - Comments have been reworded and slightly reformatted to be a little more clear.
1 parent 599646e commit 9c66f19

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

JENKINS_HOME.gitignore

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,49 @@
1-
#Learn more about Jenkins and JENKINS_HOME directory for which this file is intended.
1+
# Learn more about Jenkins and JENKINS_HOME directory for which this file is
2+
# intended.
3+
#
24
# http://jenkins-ci.org/
35
# https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins
6+
#
7+
# Note: secret.key is purposefully not tracked by git. This should be backed up
8+
# separately because configs may contain secrets which were encrypted using the
9+
# secret.key. To back up secrets use 'tar -czf /tmp/secrets.tgz secret*' and
10+
# save the file separate from your repository. If you want secrets backed up
11+
# with configuration, then see the bottom of this file for an example.
412

5-
#ignore all JENKINS_HOME except jobs directory, root xml config, and .gitignore file
13+
# ignore all JENKINS_HOME except jobs directory, root xml config, and .gitignore file
614
/*
715
!/jobs
816
!/.gitignore
917
!/*.xml
1018

11-
#ignore all files in jobs subdirectories except for folders
12-
#note: git doesn't track folders, only file content
19+
# ignore all files in jobs subdirectories except for folders
20+
# note: git doesn't track folders, only file content
1321
jobs/**
1422
!jobs/**/
1523

16-
#uncomment the following line to save next build numbers with config
24+
# Uncomment the following line to save next build numbers with config
25+
1726
#!jobs/**/nextBuildNumber
1827

19-
#exclude only config.xml files in repository subdirectories
28+
# For performance reasons, we want to ignore builds in Jenkins jobs because it
29+
# contains many tiny files on large installations. This can impact git
30+
# performance when running even basic commands like 'git status'.
31+
builds
32+
indexing
33+
34+
# Exclude only config.xml files in repository subdirectories
2035
!config.xml
2136

22-
#don't track workspaces (when users build on the master)
37+
# Don't track workspaces (when users build on the master)
2338
jobs/**/*workspace
2439

25-
#as a result only settings and job config.xml files in JENKINS_HOME will be tracked by git
40+
# Security warning: If secrets are included with your configuration, then an
41+
# adversary be able to decrypt all encrypted secrets within Jenkins config.
42+
# Including secrets is a bad practice, but the example is included in case
43+
# someone still wants it for convenience. Uncomment the following line to
44+
# include secrets for decryption with repository configuration in Git.
45+
46+
#!/secret*
47+
48+
# As a result, only Jenkins settings and job config.xml files in JENKINS_HOME
49+
# will be tracked by git.

0 commit comments

Comments
 (0)