如果没有在jenkins post build上启动,则自动启动声纳服务器

时间:2013-04-26 23:24:02

标签: shell jenkins sonarqube

我想启动声纳服务器,如果它尚未运行。 (在我构建了我的maven项目之后)。

SERVICE='sonar'

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
    echo "$SERVICE service running, everything is fine"
else
    echo "$SERVICE is not running"
    echo "Starting $SERVICE..."
    $SONAR_HOME start
fi

Jenkins在shell脚本上返回以下错误。

Waiting for Jenkins to finish collecting data
channel stopped
[workspace] $ /bin/sh -xe /var/folders/nf/744vmtn93kx6c8kx1rrlnj0r0000gn/T/hudson5680063439912543848.sh
+ SERVICE=sonar
+ ps ax
+ grep -v grep
+ grep sonar
+ echo 'sonar is not running'
sonar is not running
+ echo 'Starting sonar...'
Starting sonar...
+ start
/var/folders/nf/744vmtn93kx6c8kx1rrlnj0r0000gn/T/hudson5680063439912543848.sh: line 10: start: command not found
Build step 'Execute shell' marked build as failure
Skipping sonar analysis due to bad build status FAILURE
Finished: FAILURE

为什么失败了?

$ SONAR_HOME从终端命令行开始正常工作。

1 个答案:

答案 0 :(得分:0)

似乎$ SONAR_HOME没有设置相关性,试着 在sh文件中eche $ SONAR_HOME,看看发生了什么。