title: Jenkins-Sonar communication on Openshift
body: <p>I am making a development environnement based on Jenkins and Sonar.
  Both are placed on isolated gears.</p>
  
  <p>The Jenkins gear has been created with the Instant App option.
  The Sonar gear has been created thanks to <a href="https://github.com/wenhao/openshift-sonar" rel="nofollow">these github indications</a>.</p>
  
  <p>I created a Jenkins free-style job in order to analysis a Maven project. 
  The script used on that job is based on this <a href="http://deors.wordpress.com/2012/11/20/sonar-openshift/" rel="nofollow">wordpress article</a>.</p>
  
  <pre><code># Build script of the Job
  settingsPath=$OPENSHIFT_DATA_DIR/settings.xml
  settings="&lt;settings&gt;\n   &lt;localRepository&gt;$OPENSHIFT_DATA_DIR&lt;/localRepository&gt;\n&lt;/settings&gt;\n"
  echo $settings &gt; $settingsPath
  
  # Cleaning of the workspace
  mvn --global-settings $settingsPath clean test
  # Preparation of Sonar informations    
  export SONAR_JDBC="-Dsonar.jdbc.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/sonar?useUnicode=true&amp;characterEncoding=utf8"
  export SONAR_DRIVER=-Dsonar.jdbc.driver=com.mysql.jdbc.Driver
  export SONAR_DBUSER=-Dsonar.jdbc.username=xxx
  export SONAR_DBPASS=-Dsonar.jdbc.password=xxx
  export SONAR_URL=-Dsonar.host.url=http://sonar-alc.rhcloud.com
  export SONAR_OPTS="$SONAR_JDBC $SONAR_DRIVER $SONAR_DBUSER $SONAR_DBPASS $SONAR_URL"
  # Sonar analysis
  mvn --global-settings $settingsPath sonar:sonar $SONAR_OPTS
  </code></pre>
  
  <p>On the execution of the mvn sonar:sonar command, I have the following error:</p>
  
  <pre><code>Can not execute SonarQube analysis: Fail to connect to database: Cannot create PoolableConnectionFactory (Communications link failure
  </code></pre>
  
  <p>Here is the stacktrace corresponding to this error:</p>
  
  <pre><code>[INFO] Scanning for projects...
  [INFO]                                                                         
  [INFO] ------------------------------------------------------------------------
  [INFO] Building ClientEvalcolor 1.0
  [INFO] ------------------------------------------------------------------------
  [INFO] 
  [INFO] --- sonar-maven-plugin:2.1:sonar (default-cli) @ ClientEvalcolor ---
  [INFO] SonarQube version: 3.3.1
  [INFO] [03:28:09.324] Create JDBC datasource for jdbc:mysql://xxx.xxx.xxx.xxx:3306/sonar?useUnicode=true&amp;characterEncoding=utf8
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 12.634s
  [INFO] Finished at: Mon Nov 25 03:28:10 EST 2013
  [INFO] Final Memory: 12M/182M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.1:sonar (default-cli) on project ClientEvalcolor: Can not execute SonarQube analysis: Fail to connect to database: Cannot create PoolableConnectionFactory (Communications link failure
  [ERROR] 
  [ERROR] The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.): No route to host
  [ERROR] -&gt; [Help 1]
  [ERROR] 
  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR] 
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  Build step 'Execute shell' marked build as failure
  Finished: FAILURE
  </code></pre>
  
  <p>I know that an Openshift mysql database isn't accessible from a remote server, but Sonar seems to be runnable on Openshift, and the article that I previously linked successfully did it. </p>
  
  <p>Do you have any idea about how to fix that ? </p>
  
  <p>Thank you,
  Alvaro C.</p>