How do I get TeamCity to understand PROJECT_DIR variable in Run Configuration?
Hi,
I have a Run Configuration which includes the variable PROJECT_DIR.
In IntelliJ it is fine but when I use the Run Configuration in TeamCity it doesn't know who to resolve this variable.
I'm using TeamCity 6.5.2 and IntelliJ 10.5.1.
Any help would be much appreciated.
Cheers,
David
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All myproject Tests" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="myproject" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="PACKAGE_NAME" value="" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -Xmx768M -Djava.awt.headless=true -Duser.language=en -Duser.region=AU -Dconfig.file=$PROJECT_DIR$/myproject/config/standard.conf" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>
Please sign in to leave a comment.
This is strange, $PROJECT_DIR$ should be resolved without problems. Can you provide a build log, or sample project to reproduce this issue?
Hi Pavel,
Thanks for your reply.
The exception from the Build Log is shown below. It seems that TeamCity has not substituted PROJECT_DIR.
Each test tried to read my config file so they all fail with the same exception.
I tried defining it as a Configuration Parameter and an Environment variable and that didn't work.
Regards,
David
myproject.framework.exception.MyProjectBusinessRuleException: couldn't read config file $PROJECT_DIR$/myproject/config/standard.conf
at myproject.framework.config.Config.createConfiguration(Config.java:165)
at myproject.framework.config.Config.loadFile(Config.java:96)
at myproject.framework.config.Config.replace(Config.java:84)
at myproject.framework.config.Config.initOnDemand(Config.java:75)
at myproject.framework.config.Config.getConfiguration(Config.java:480)
at myproject.framework.config.Config.contains(Config.java:182)
at myproject.framework.testingframework.ConfigFixture.setUp(ConfigFixture.java:43)
at myproject.framework.testingframework.ObjectRegistryFixture.setUp(ObjectRegistryFixture.java:23)
at highlander.billing.charging.usage.flowey.ChargerTestCase.setUp(ChargerTestCase.java:47)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
at jetbrains.buildServer.agent.ideaRunner.junit.JUnit4RunnerImpl.runTestClasses(JUnit4RunnerImpl.java:29)
at jetbrains.buildServer.agent.ideaRunner.junit.JUnitLauncher.main(JUnitLauncher.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at jetbrains.buildServer.agent.ideaRunner.MainClassLauncher.main(MainClassLauncher.java:46)
Caused by: org.apache.commons.configuration.ConfigurationException: Cannot locate configuration source $PROJECT_DIR$/highlander/config/standard.conf
at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:215)
at myproject.framework.config.Config.createConfiguration(Config.java:162)
... 34 more
Hi Again,
I've attached a sample project the illustrate the problem clearly.
If you configure the "All tests" run configuration in TeamCity it will not run because it won't resolve the $PROJECT_DIR$ variable.
I've also raised a bug for this http://youtrack.jetbrains.net/issue/TW-17674?projectKey=TW&query=%22run+configuration%22
Regards,
David
Attachment(s):
testprojectdir.zip