I am new to Hudson / Jenkins and was wondering if there is a way to check in Hudson's configuration files to source control.
Ideally I want to be able to click some button in the UI that says 'save configuration' and have the Hudson configuration files checked in to source control.
There is a new SCM Sync Configuration plug-in which does exactly what you are looking for.
I haven't actually tried this yet, but it looks promising.
I checked in hudson entirely, you could use this as a starting point https://github.com/morkeleb/continuous-delivery-with-hudson
There are benefits to keeping entire hudson in git. All config changes are logged and you can test the testup quite easily on one machine and then update the other machine(s) using git pull.
We used this as a boilerplate for our hudson continuous delivery setup at work.
Regards Morten
Answer from Mark (https://stackoverflow.com/a/4066654/142207) should work for SVN and Git (although Git configuration did not work for me).
But if you need it to work with Mercurial repo, create a job with following script:
To manually manage your configuration with Git, the following .gitignore file may be helpful.
See https://gist.github.com/780105 and http://bit.ly/i58rg2 for more details.
The way I prefer is to exclude everything in the Jenkins home folder except the configuration files you really want to be in your VCS. Here is the
.gitignore
file I use:This ignores everything (
*
) except (!
).gitignore
itself, the jobs/projects, the plugin and other important and user configuration files.It's also worth considering to include the
plugins
folder. Annoyingly updated plugins should be included...Basically this solution makes it easier for future Jenkins/Hudson updates because new files aren't automatically in scope. You just get on the screeen what you really want.
You can find configuration files in Jenkins home folder (e.g.
/var/lib/jenkins
).To keep them in VCS, first login as Jenkins (
sudo su - jenkins
) and create its git credentials:Then initialize, add and commit the basic files such as:
also consider creating
.gitignore
with the following files to ignore (customize as needed):Then add it:
git add .gitignore
.When done, you can add job config files, e.g.
Finally add and commit any other files if needed, then push it to the remote repository where you want to keep the config files.
When Jenkins files are updated, you need to reload them (Reload Configuration from Disk) or run
reload-configuration
from Jenkins CLI.