Starting and Accessing Hudson

本文详细介绍了如何通过内置的Winstone Servlet容器执行Hudson,并提供了启动脚本、HTTPS配置和常见命令行参数说明,旨在帮助开发者高效地部署和管理Hudson。

Starting Hudson

  The easiest way to execute Hudson is through the built in Winstone servlet container. You can execute Hudson like this:

java -jar hudson.war

    Of course, you probably want to send the output of Hudson to a log file, and if you're on Unix, you probably want to use nohup:

nohup java -jar hudson.war > $LOGFILE 2>&1

Accessing Hudson

    To see Hudson, simply bring up a web browser and go to URL http://myServer:8080 where myServer is the name of the system running Hudson

Command Line Parameters

    Hudson normally starts up using port 8080, however, if you have other web services starting up, you might find that this port is already taken, you can specify a different port by using the --httpPort=$HTTP_PORT where $HTTP_PORT is the port you want Hudson to run on. Other command line parameters include:

Command Line ParameterDescription
--httpPort=$HTTP_PORTRuns Hudson listener on port $HTTP_PORT using standard http protocol. The default is port 8080. To disable (because you're using https), use port -1.
--httpListenAddress=$HTTP_HOSTBinds Hudson to the IP address represented by $HTTP_HOST. The default is 0.0.0.0 — i.e. listening on all available interfaces.
--httpsPort=$HTTP_PORTUses HTTPS protocol on port $HTTP_PORT
--httpsListenAddress=$HTTPS_HOSTBinds Hudson to listen for HTTPS requests on the IP address represented by $HTTPS_HOST.
--argumentsRealm.passwd.$ADMIN_USERSets the password for user $ADMIN_USER. If Hudson security is turned on, you must log in as the $ADMIN_USER in order to configure Hudson or a Hudson project. NOTE: You must also specify that this user has an admin role. (See next argument below).
--argumentsRealm.roles.$ADMIN_USER=adminSets that $ADMIN_USER is an administrative user and can configure Hudson if Hudson's security is turned on. See Securing Hudson for more information.

Hudson passes all command line parameters to the Winstone servlet container, so you can get more information by looking at the Winstone Command Line Parameter Reference

   

Be Careful with Command Line Parameters. Hudson ignores command line parameters it doesn't understand instead of producing an error. Be careful when using command line parameters and make sure you have the correct spelling. For example, the parameter needed for defining the Hudson administrative user is --argumentsRealm and not --argumentRealm.

A very simple init script

The following script is for Ubuntu based systems. For a good startup/shutdown script for Red Hat based systems, see  http://www.wakaleo.com/component/content/article/206
#!/bin/sh

DESC="Hudson CI Server"
NAME=hudson
PIDFILE=/var/run/$NAME.pid
RUN_AS=hudson
COMMAND=java -jar /home/hudson/hudson.war

d_start() {
	start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --exec $COMMAND
}

d_stop() {
	start-stop-daemon --stop --quiet --pidfile $PIDFILE
	if [ -e $PIDFILE ]
		then rm $PIDFILE
	fi
}

case $1 in
	start)
	echo -n "Starting $DESC: $NAME"
	d_start
	echo "."
	;;
	stop)
	echo -n "Stopping $DESC: $NAME"
	d_stop
	echo "."
	;;
	restart)
	echo -n "Restarting $DESC: $NAME"
	d_stop
	sleep 1
	d_start
	echo "."
	;;
	*)
	echo "usage: $NAME {start|stop|restart}"
	exit 1
	;;
esac

exit 0

In Ubuntu 9.04-Server this init-script doesn't work. You have to change the start line to

start-stop-daemon --start --quiet --background -m --pidfile $PIDFILE --chuid $RUN_AS --exec /usr/bin/java -- -jar /opt/hudson/hudson.war

Using HTTPS with an existing certificate

If you're setting up Hudson using the built-in Winstone servlet and want to use an existing certificate for HTTPS you'll need to do some converting. First, convert your pem-formatted certificate and key files to a format that the Java keytool can use:

openssl pkcs12 -export -in /path/to/cert -inkey /path/to/key -name "Whatever you want" -out keystore.p12

Then use the Java keytool to create a new keystore with that file (keep track of the password you use for the store, you'll need it in the next step):

keytool -importkeystore -srckeystore keystore.p12 -srcstoretype pkcs12 -destkeystore /path/to/hudsonhome/winstone.ks -deststoretype JKS

Finally, add these parameters to your command (filling in or changing values as needed):

--httpPort=-1 --httpsPort=443 --httpsKeyStore=/path/t/hudsonhome/winstone.ks --httpsKeyStorePassword=yourchosenpass


转载于:https://my.oschina.net/aiguozhe/blog/34400

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值