Checkin CruiseControl.net config file - version-control

Is there any cruisecontrol.net extension, that monitor the event when the config file modified, and will check-in the config file into the source control?
I found on the cruise-control documentation a method that does the opposite, which is when we modify the config file in the source control, cruise-control will update the file and apply the changes.
But my concern is when someone change the config file from the server, then is there a way to track that?
My thought that by building extension that listen to the event when the config file change, we can push the code to source control, and I am wondering if there is already somebody did that?
Thanks

I agree with #Christopher Karper. I've seen it work well where the changes to the config file are checked in and then CC.NET pulls the changes down.
If you really need to monitor the area on the continuous integration server where the file is you could use a File System Source control block to do that. The simplest way I can think to get the file checked in would be to use an exec task to run svn.exe.

You've got that backwards from the way I've seen most implementations.
If you set up a project in your source control, and cruisecontrol.net that is just for the config file, you can update it in the source repos, and have cc.net pull down the updated version each time...
Just a thought.

Related

Untrack files without removing from remote repository

In our company, we just started using Mercurial and we are facing the following problem:
We have some files in the remote repository that are changed by each developer to add some local configuration but these files must never be changed in the remote repository.
Is there a way to tell Mercurial to stop tracking those files locally without making any change to the file on the remote repository?
We tried with hg forget <file> but as I understand, this will remove the file from the remote repository.
We also tried adding those files to .hgignore file, but somehow the files are not really being ignored, I guess Mercurial does this because the files are already being tracked.
So far, we are just ignoring the files when we perform a commit and we use shelve to maintain and restore our local changes after an Update, but it's starting to be a really tedious task.
Thanks in advance for any help.
EDIT: Although it didn't completely fix what we wanted to, accepted answer is the best approach. Our problem is probably a result of a bad design.
If the file you want unchanged is, for example, config.cfg, check in a config_template.cfg, forget config.cfg if it is already tracked, and add config.cfg to the ignore list. Then, a build rule can create config.cfg from the template if it does not already exist.
A user will then have a starting config.cfg that they can customize without checking it in.
You could use the configuration [defaults] section to add some "--exclude" options to usual commands (see my answer to Mercurial hg ignore does not work properly ) for more details.
But.. be careful that it is dangerous to silently ignore modifications to files and also that this [defaults] section has been marked as deprecated (it is still present in 2.9.2).
IMHO it's a wrong approach to have a file in the repository which every person needs changed anyway - it's an indication that you do not want to have it tracked at all.
Change the file to config.sample, and have your programme create a default config upon first start (thus when there's no existing config file) and have every developer use the config file as s/he needs.
And I see Mark Tolnen's answer only now :)

Protecting the sensitive files from pushing to version control

Here's the problem: I'm developing a few projects that need to somehow store credentials used for external services - for example, an e-mail address and password. I figured it falls into "configuration" and decided to move the variable data into a separate file the program reads from. I don't want this file to be pushed to upstream though, because in some of my smaller programs, written for personal needs, I test on a production environment and the data are usually quite sensitive.
On the other hand, I don't want a basic .gitignore solution or its equivalent - instead of not uploading the file at all, I'd prefer to send another file in its place, an example configuration file, while keeping the "real" file on its place on my computer. Is there any simple way of achieving it?
If you need more details to answer the question, I'd prefer an answer regarding Git VCS, Python scripts and Linux OS.
One possible solution:
Commit and push a "sample" config file. Then, make the modifications you want to the local config file. It will now be marked as modified in Git.
Use git update-index --assume-unchanged config to permanently ignore future local modifications to the config file (use --no-assume-unchanged to resume tracking modifications).
This way, you will have a sample config in the upstream repo, a customized config in your repo, and you will not accidentally commit the changed config because Git will not mark it as modified.
Another thing you can do is use .gitattributes filters. It lets you specify certain files to pipe through a unix command. You could write a ruby script to scrub out your passwords and replace them with dummy values, or just use sed or awk. You could go a lot crazier than that and use it for some really dangerous things also, heh. See this other answer for some details.

SVN - ignoring files already in repository

I have a configuration file in my project which needs to be in the repository (so new developers get it when they checkout the project). Each developer might change some values in the file locally - these changes should not be committed and I don't want them showing in the synchronization menu (I'm using eclipse and subversive if it matters).
Note that I can't just set the svn:ignore property since it only works on files that aren't under version control - but I do want to keep a base version of the file in the repository. How can I avoid the file showing in synchronization without deleting it from repository?
EDIT: A better description - what I actually need is to be able to set a "read-only" property on the config file, so it can't be changed in the repository as long as the property is on. Do you know anything like this?
Thanks
I do this by having a base version of the file checked-in as foo.base, and svn lock this so that it's read-only on checkout. Then have each developer copy this file to their own personal foo file, which is ignored by svn-ignore.
You can't ignore files which are already under version control. The only way to ignore such files is first delete those files do a commit and after that change the svn:ignore property and do a second commit.
If you like to have a kind of Base-Version use a template which has a different name.
You can version template under different name
OR
Read this answer
once u check out, u can lock it, and once it is locked, others will not be able to commit(make changes to svn) that file. see image below
My solution is that a compile time script creates a copy from the original template file if it does not exist. This copy can be put on the ignore list. I feel that locking a file for this purpose abuses the locking feature (it was not created for this).

Mercurial. Version control and deployment. Different config files. How to?

I have a setup as follows.
A private repository at bitbucket where I keep the 'master' repository.
A repository on my server which acts as the 'live' website.
A repository on my laptop which acts as my working copy.
My process is as follows. I make a change to a file in my local repository. I commit these locally. I push these changes to bitbucket. I then pull these changes from my bitbucket to the webserver.
The problem that I have however is that my local copy utilizes different configuration settings for databases, paths etc, ergo what I want is my 'config.php' file at bitbucket to contain the server settings, and the config.php on my local host to contain local settings.
I believe this can be achieved with .hgignore but i have had no success researching.
The problem i encounter is that i make my server settings file, push it to bitbucket, 'forget' the file in my local repository, create a .hgignore, and then recreate the file. However when i 'forget' the file TortoiseHG notices and asks me to commit the change to bitbucket....
Any ideas would be greatly appreciated.
Thanks
Additional Points.
Following the advice below I have developed a setup as follows:
I have my local repository on my laptop where i do my edits.
I have bitbucket which is essentially the 'main' repository - if any other developers join the team they clone this.
I have my live repository on my web host.
On my live repository I have a .hgignore file whichs ignores the respective config files.
As such when I do hg pull from my host, it pulls the repository as is with the localhost configuration files, but when i type hg update (to the live working copy), these files are ignored/not updated.
Could someone clarify as to if i have understood this correctly, and as to whether this is a suitable way of achieving what I want?
Thanks
.hgignore only ignores files if they are not versioned already, so I don’t think your idea in the question will work.
The common approach regarding local configuration is generally a variation on the same theme, like of one of the following:
Do not check in the config.php at all. You can check in a config.example.php with the most common settings, and document in the README that users have to copy it to config.php and then edit it.
Put any shared settings in config.php, and add an include statement to point to an unversioned file with settings specific to the machine, e.g. config.local.php. You can also provide an config.local.example.php-file for this.
Like 2, but the config.php contains all default settings and the local file has the ability to override them.
Check in a config.dev.php and config.server.php-file containing the settings for both environments, and then have an unversioned config.php which includes one of the above files. Advantage is that the configurations themselves are versioned and you can update them.
Which of these variations to pick, or whether you make another variation, depends on your environment.
The basic idea for working with version control and different configuration files is always the same, but I don't know enough PHP to give a detailed answer how you can do this in PHP.
I answered a similar question for .net/Visual Studio a few months ago, so I'll just give you the link to this answer and try to describe the basic idea again, but this time language-agnostic:
For your use case, the basic idea is to have two config files in the repository, one with your local data and one with your server data, for example like this:
config.local.php
config.server.php
The "real" config.php is not in the repository, and it should be in .hgignore, so it never will be in the repository either.
After pulling, you need to run something that copies one of these files (the "correct" one depending on the current environment, local or server) to config.php.
And exactly this last part is the part that I can not answer in detail, because I don't know how to do that in PHP and/or on a web server because I'm a .net/Windows guy.
As far as I know, deploying a PHP site is just copying the files on the web server, so there is no "build/compile" step where the copying/renaming of the config file could be done (where I would do it in .net). Correct me if I'm wrong...
EDIT:
Thomas, I'm not sure if I understood your edits correctly. Your "local" repository on your laptop and your "live" repository on your webserver are basically clones of your "main" repository on Bitbucket, correct?
If yes, are you saying that you have different .hgignore files in the different clones?? That's the part that confuses me.
No matter how you actually do it in the end (there are several possibilities to deal with configuration files, see below), the .hgignore file should be the same in all clones of your repository.
So all your repositories (no matter which clone on which machine) should all contain the same configuration file(s).
Then, you only need to make sure that different configurations are used in different environments. There's already an excellent list of different ways to achieve this in Lauren Holst's answer, so I'll just point you there.
As Laurens Holst already said, we can't tell which of these ways is the best for you - it depends on your environment.
You might want to check here. If both the config file and .hgignore are commited, the .hgignore will have no effect. You could also add a domain check conditional:
$domain = $_SERVER['HTTP_HOST'];
if ($domain=="localhost") {
//local copy config
}
else if ($domain=="yourdomain.com") {
//webserver config
}

Conditional Mercurial Ignore File

I have a file in mercurial that I want dev machines to pull the file, but I want the deployment server to NOT pull the file (it has special mods to it that the dev machines don't have). Is this possible, or should I just have a custom push to server solution instead of just doing an hg pull?
A typical way to do this would be to do the following:
You store a copy of each file in the repository, and name them correctly. For instance, if the file in question is web.config, you would store the following two in the repository:
web.server.config
web.dev.config
Then you would add a built step to ensure the right file was copied to the actual web.config file, you could use a batch file:
if "%COMPUTERNAME%" == "SERVER" copy web.server.config web.config
if not "%COMPUTERNAME%" == "SERVER" copy web.dev.config web.config
Then you would ignore web.config itself through .hgignore:
glob:web.config
A variant of Karlsen's answer that I always use.
I have /config or /etc directory in the project. That directory will often contain sample configs like:
dev.yaml
ci_server.yaml
Then my apps pull from /etc/app.yaml which is a symlink to the correct config depending on the host it's being run on.
The best think about doing it this way is you don't have variant code paths (the batch script branches) which eliminates a potential bug vector. This allows you to exercise the same code path that will be used in production (down to where to look for the override file).
Is this something that can be solved outside version control? For instance, include the file in all copies of the repository, but enable or disable its use with environment variables or something similar. This doesn't sound like something most version control systems are built to handle, unless you use nasty hacks to do things like add/remove/patch files after updating.
One option is to create a special hgignore file for the deployment server, that could or could not be included in the repository. Then in the server's hgrc file specify the path to the special hgignore file with the ignore variable.
This would ensure that updates to file would be ignored by the deployment server but could still be updated as usual for the development machines.