有没有办法用外部sonar.properties文件启动sonarqube服务器?

有没有办法用外部sonar.properties文件启动sonarqube服务器?,sonarqube,sonarqube-5.0,Sonarqube,Sonarqube 5.0,我想知道是否有办法启动一个带有外部sonar.properties和wrapper.conf文件的SonarQube(5.0.1)服务器 我正在研究类似于apache“-f”选项的东西- /apache2/bin/apachectl -f /path/to/httpd.conf 谢谢 ======================================================== 正如在下面的回答中提到的,我尝试使用环境变量引用属性。这适用于某些属性。例如:sonar.jdbc

我想知道是否有办法启动一个带有外部sonar.properties和wrapper.conf文件的SonarQube(5.0.1)服务器

我正在研究类似于apache“-f”选项的东西-

/apache2/bin/apachectl -f /path/to/httpd.conf
谢谢

========================================================

正如在下面的回答中提到的,我尝试使用环境变量引用属性。这适用于某些属性。例如:sonar.jdbc.username和sonar.jdbc.password

对于我来说,它不适用于具有多个环境变量的属性值

url=jdbc:mysql://${env:mysql\u HOST}:${env:mysql\u PORT}/sonar= ?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true

这是我得到的一个例外-

2015.03.17 11:48:33 INFO  web[o.s.c.p.Database]  Create JDBC datasource for=  jdbc:mysql://${env:MYSQL_HOST}:${env:MYSQL_PORT}/sonar?useUnicode=3Dtrue&c=
haracterEncoding=3Dutf8&rewriteBatchedStatements=3Dtrue
2015.03.17 11:48:33 ERROR web[o.a.c.c.C.[.[.[/sonar]]  Exception sending co= ntext initialized event to listener instance of class org.sonar.server.plat= form.PlatformServletContextListener
java.lang.IllegalStateException: Can not connect to database. Please check = connectivity and settings (see the properties prefixed by 'sonar.jdbc.').
==========================================================

我也尝试过只使用一个env变量-

$echo $MYSQL_DB_URL
jdbc:mysql://devdbXXX:6000/sonar?useUnicode=true
获取此异常-

--> Wrapper Started as Daemon
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.


WrapperSimpleApp: Encountered an error running main: org.sonar.process.MessageException: Bad format of JDBC URL: ${env:MYSQL_DB_URL}
org.sonar.process.MessageException: Bad format of JDBC URL: ${env:MYSQL_DB_URL}
<-- Wrapper Stopped
-->包装器作为守护进程启动
正在启动JVM。。。
包装器(版本3.2.3)http://wrapper.tanukisoftware.org
1999-2006塔努基软件有限公司版权所有。保留所有权利。
WrapperSimpleApp:运行main:org.sonar.process.MessageException时遇到错误:JDBC URL的格式错误:${env:MYSQL\u DB\u URL}
org.sonar.process.MessageException:JDBC URL的格式错误:${env:MYSQL\u DB\u URL}

在UBUNTU中:是的,你可以给一个外部文件。如果在sonarqube bin文件夹中看到sonar.sh文件

#! /bin/sh

#
# Copyright (c) 1999, 2006 Tanuki Software Inc.
#
# Java Service Wrapper sh script.  Suitable for starting and stopping
#  wrapped Java applications on UNIX platforms.
#

#-----------------------------------------------------------------------------
# These settings can be modified to fit the needs of your application

# Default values for the Application variables, below. 
# 
# NOTE: The build for specific applications may override this during the resource-copying
# phase, to fill in a concrete name and avoid the use of the defaults specified here.
DEF_APP_NAME="SonarQube"
DEF_APP_LONG_NAME="SonarQube"

# Application
APP_NAME="${DEF_APP_NAME}"
APP_LONG_NAME="${DEF_APP_LONG_NAME}"

# Wrapper
WRAPPER_CMD="./wrapper"
WRAPPER_CONF="../../conf/wrapper.conf"

# Priority at which to run the wrapper.  See "man nice" for valid priorities.
#  nice is only used if a priority is specified.
PRIORITY=

# Location of the pid file.
PIDDIR="."

您可以在这里定义包装文件的路径
wrapper\u CONF=
,对于sonar.properties,您可以在sonarqube CONF文件夹中创建一个文件链接,并将其重定向到保存文件的路径。还有一个更难的选项是编辑上面的start.sh文件,以接受这些参数作为标志。(例如sonar属性的
-sp
,包装器配置的
-wc

sonar.properties中的值可以通过引用环境变量进行外部化

sonarqube/5.0.1/conf/sonar.properties标题>

# Property values can:
 # - reference an environment variable, for example sonar.jdbc.url= ${env:SONAR_JDBC_URL}

看起来这种方法需要最少的文件操作,解决了我不想硬编码属性值的问题,因为属性值随环境而变化。

创建指向sonar.properties的文件链接就像更改rpm一样。我正在寻找一个解决方案,我不必触及rpm文件结构。感谢您的输入,我将测试此选项。我的问题特定于sonar.properties文件,感谢您在wrapper conf上的输入。使用符号链接构建sonqrqube rpm对我不起作用,因为目标会随环境(dev/qa/prod等)而变化。