Skip to content

Commit 81ebaec

Browse files
authored
Improved JENKINS_HOME example (github#3332)
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 589831e commit 81ebaec

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

JENKINS_HOME.gitignore

+33-8
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,50 @@
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
14+
# .gitignore file.
615
/*
716
!/jobs
817
!/.gitignore
918
!/*.xml
1019

11-
#ignore all files in jobs subdirectories except for folders
12-
#note: git doesn't track folders, only file content
20+
# Ignore all files in jobs subdirectories except for folders.
21+
# Note: git doesn't track folders, only file content.
1322
jobs/**
1423
!jobs/**/
1524

16-
#uncomment the following line to save next build numbers with config
25+
# Uncomment the following line to save next build numbers with config.
26+
1727
#!jobs/**/nextBuildNumber
1828

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

22-
#don't track workspaces (when users build on the master)
38+
# Don't track workspaces (when users build on the master).
2339
jobs/**/*workspace
2440

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

0 commit comments

Comments
 (0)