I have sonarqube server 4.0 and sonar-ant-task-2.1. My sonar target runs fine on my local RHEL 5 machine but as soon as I promote it to a shared RHEL 5 environment it will be run by a user whose home directory is "/dev/null" apparently. I can't change that.
I get the following error: Unable to create user cache/dev/null/.sonar/cache Caused by: java.io.IOException: Unable to create directory /dev/null/.sonar/cache
I set the following two properties:
<property name="sonar.working.directory" value="dirWhereUserHasAccess"/>
<property name="sonar.userHome" value="dirWhereUserHasAccess"/>
These properties seem to have the desired affect locally however when run on the shared environment the sonar.userHome is not used. I get the same error. It's trying to use /dev/null.
How can I get sonar to stop trying to access /dev/null for this cache?
Bug description is below. Jira task created https://jira.codehaus.org/browse/SONARPLUGINS-3349
Uncovered bug... Submitted to the user group: I believe there is a problem in sonar-ant-task-2.1->sonar-runner-2.4->sonar-runner-impl->Jars35
This line does not take into account the sonar.userHome property. When the ant-task runs the Jars35 invokes the FileCacheBuilder.build() without setting the userHome. Therefore, the builder chooses
System.getProperty("user.home") + File.separator + ".sonar"
which, in my case is not a directory where the user has r/w access (/dev/null). Therefore the analysis fails with this error:
... Caused by: java.io.IOException: Unable to create directory /dev/null/.sonar/cache at org.apache.commons.io.FileUtils.forceMkdir(FileUtils.java:1748) at org.sonar.home.cache.FileCache.createDir(FileCache.java:155) ... 30 more
I think the Jars35 class needs to be able to set the userHome or this property will not have the intended affect. Even if the user has a valid home directory some cached jars will cache into the system user.home and the rest (after being loaded with the bootstrap implementation) will be loaded into the appropriate sonar.userHome location.
FileCacheProvider using the sonar.userHome setting to build the FileCache through the FileCacheBuilder. https://github.com/SonarSource/sonar/blob/master/sonar-batch/src/main/java/org/sonar/batch/bootstrap/FileCacheProvider.java#L34
I'll update with jira issue if entered