Use specific PHP file for build configuration

Hi

I have added created a project in TeamCity from a repository URL, and added a test build to the project.
The project is a PHP website using a MySQL database, with the connection information for the database placed in a PHP file. The connection information can then be set to the specific database I want to use depending on the environment; production, development, testing etc.

How do I in TeamCity add a PHP file with this database connection information to a build configuration, so that I can have the PHP system connect to a test database when running unittests?

Or is it not the build configuration which I should be able to associate with this specific PHP file?

3 comments
Comment actions Permalink

Hi Anders,

Do you have one PHP file with the settings for prod/dev with environment variable condition? If yes, then you can use build configuration parameter in TeamCity to specify needed environment variables.

0
Comment actions Permalink

Hi

No, we do not have both configurations for prod and dev in the project. When we deploy the system to a server, we are making a new config file with the specific database, username and password for the installation. And we do not want these settings for the prod installation present in the projects git repo.

0
Comment actions Permalink

You can store needed parameters as configuration parameters of type password in TeamCity. This will require creating the configuration file during the build step, based on these configuration parameters
Another option is to put this files to a separate VCS root.

Also you can use installing agent tools plugin to distribute settings file from the server to all the agents and take this file from <Agent Home Directory>/tools during the build.

0

Please sign in to leave a comment.