HowTo: Continuous Integration for Rails applications in GIT with TeamCity.

I’ve just setup RSpec tests on TeamCity 4.0.2 buildserver for my rails project that is located under GIT version control!

teamcity_rspec_demo

To install git plugin see instructions. If you don’t want to build git plugin manually your can take my build (22 march, 2009). Also I zipped it with correct folder structure (download gitagentzip.png and rename to “gitAgent.zip” )

Also don’t forget to:

1. SetupĀ Project Directory (Server): path in VCS settings. This is destination path to folder where Git plugin will clone git repository.

E.g. your VCS Git settings will be like this:

teamcity_git_settings

If you leave Project Directory(Server) empty you will see NullPointer Exception:

jetbrains.buildServer.serverSide.ExecutionException: Unable to collect changes jetbrains.buildServer.serverSide.ExecutionException: Unable to collect changes at jetbrains.buildServer.serverSide.impl.BuildChangesCollector.collectChanges(BuildChangesCollector.java:1) at jetbrains.buildServer.serverSide.impl.BuildStarter$1.run(BuildStarter.java:21) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:637) Caused by: java.util.concurrent.ExecutionException: jetbrains.buildServer.vcs.VcsException: ‘/usr/bin/git clone -n ssh://git@unit-249/~/browser.git /Users/romeo/app/TeamCity/work/git’ command failed. stderr: fatal: destination directory ‘/Users/romeo/app/TeamCity/work/git’ already exists. at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222) at java.util.concurrent.FutureTask.get(FutureTask.java:83) at jetbrains.buildServer.serverSide.impl.CancelableTaskHolder.waitForTaskToComplete(CancelableTaskHolder.java:9) at jetbrains.buildServer.serverSide.impl.dependency.TopBuildDependencyGraphImpl.doCollectChanges(TopBuildDependencyGraphImpl.java:3) at jetbrains.buildServer.serverSide.impl.dependency.TopBuildDependencyGraphImpl.access$000(TopBuildDependencyGraphImpl.java:49) at jetbrains.buildServer.serverSide.impl.dependency.TopBuildDependencyGraphImpl$3.run(TopBuildDependencyGraphImpl.java:2) at jetbrains.buildServer.serverSide.impl.dependency.TopBuildDependencyGraphImpl$3.run(TopBuildDependencyGraphImpl.java:1) at jetbrains.buildServer.serverSide.impl.dependency.TopBuildDependencyGraphImpl$4.run(TopBuildDependencyGraphImpl.java:1) at jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAs(SecurityContextImpl.java:24) at jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAsSystem(SecurityContextImpl.java:31) at jetbrains.buildServer.serverSide.impl.dependency.TopBuildDependencyGraphImpl.runAsSystem(TopBuildDependencyGraphImpl.java:60) at jetbrains.buildServer.serverSide.impl.dependency.TopBuildDependencyGraphImpl.collectChanges(TopBuildDependencyGraphImpl.java:54) at jetbrains.buildServer.serverSide.impl.dependency.TopBuildDependencyGraphImpl.collectChanges(TopBuildDependencyGraphImpl.java:75) at jetbrains.buildServer.serverSide.impl.BuildChangesCollector.collectChanges(BuildChangesCollector.java:0) … 7 more Caused by: jetbrains.buildServer.vcs.VcsException: ‘/usr/bin/git clone -n ssh://git@unit-249/~/browser.git /Users/romeo/app/TeamCity/work/git’ command failed. stderr: fatal: destination directory ‘/Users/romeo/app/TeamCity/work/git’ already exists. at org.hivedb.teamcity.plugin.commands.CommandUtil.commandFailed(CommandUtil.java:32) at org.hivedb.teamcity.plugin.commands.CommandUtil.checkCommandFailed(CommandUtil.java:15) at org.hivedb.teamcity.plugin.commands.CommandUtil.runCommand(CommandUtil.java:39) at org.hivedb.teamcity.plugin.commands.GitCommand.exec(GitCommand.java:37) at org.hivedb.teamcity.plugin.commands.CloneCommand.run(CloneCommand.java:31) at org.hivedb.teamcity.plugin.GitVcs.getCurrentVersion(GitVcs.java:35) at jetbrains.buildServer.buildTriggers.vcs.VcsChangesLoader.getCurrentVersion(VcsChangesLoader.java:43) at jetbrains.buildServer.vcs.impl.VcsManagerImpl.getVersionsForAllRoots(VcsManagerImpl.java:415) at jetbrains.buildServer.vcs.impl.VcsManagerImpl.loadChanges(VcsManagerImpl.java:513) at jetbrains.buildServer.serverSide.impl.auth.SecuredVcsManager.loadChanges(SecuredVcsManager.java:72) at jetbrains.buildServer.vcs.impl.VcsChangesCollectorImpl$3.call(VcsChangesCollectorImpl.java:2) at jetbrains.buildServer.vcs.impl.VcsChangesCollectorImpl$3.call(VcsChangesCollectorImpl.java:1) … 5 more

2. SetĀ VCS checkout mode to “Automatically on agent (if supported by VCS)”

3. git should be in system PATH

And my Rake build runner settings are:

teamcity_rake_settings

Enjoy!

Author: Roman Chernyatchik

I'm interested in bioinformatics, software development, IoT.

Leave a comment