修改Ubuntu下的jenkins端口号

很快就可以使用了。而且这种方法能够方便的升级到最新版本。不过端口号是8080,我的另一个程序用到了8080,怎么修改呢?

网上一些方法介绍通过nginx或者apache将80端口映射到8080, 还有人说用iptables, 这都是间接迂回。我就是不想让jenkins占用8080端口。

通过检查/etc/init.d/jenkins脚本,发现其实就需要做两步:

1. 修改do_start函数的check_tcp_port命令,端口号从8080换成8082

[plain]  view plain  copy
  1. #                                                                                                                                                                                                                      
  2. # Function that starts the daemon/service                                                                                                                                                                              
  3. #                                                                                                                                                                                                                      
  4. do_start()  
  5. {  
  6.     # the default location is /var/run/jenkins/jenkins.pid but the parent directory needs to be created                                                                                                                
  7.     mkdir `dirname $PIDFILE` > /dev/null 2>&1 || true  
  8.     chown $JENKINS_USER `dirname $PIDFILE`  
  9.     # Return                                                                                                                                                                                                           
  10.     #   0 if daemon has been started                                                                                                                                                                                   
  11.     #   1 if daemon was already running                                                                                                                                                                                
  12.     #   2 if daemon could not be started                                                                                                                                                                               
  13.     $DAEMON $DAEMON_ARGS --running && return 1  
  14.   
  15.     # Verify that the jenkins port is not already in use, winstone does not exit                                                                                                                                       
  16.     # even for BindException                                                                                                                                                                                           
  17.     check_tcp_port "http" "$HTTP_PORT" "8082" || return 1  
  18.   
  19.     # If the var MAXOPENFILES is enabled in /etc/default/jenkins then set the max open files to the                                                                                                                    
  20.     # proper value                                                                                                                                                                                                     
  21.     if [ -n "$MAXOPENFILES" ]; then  
  22.         [ "$VERBOSE" != no ] && echo Setting up max open files limit to $MAXOPENFILES  
  23.         ulimit -n $MAXOPENFILES  
  24.     fi  
  25.   
  26.     # --user in daemon doesn't prepare environment variables like HOME, USER, LOGNAME or USERNAME,                                                                                                                     
  27.     # so we let su do so for us now                                                                                                                                                                                    
  28.     $SU -l $JENKINS_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS -- $JAVA $JAVA_ARGS -jar $JENKINS_WAR $JENKINS_ARGS" || return 2  
  29. }  


2.修改/etc/default/jenkins文件,将端口8080改成8082


然后重新启动jenkins, 检查一下:

[plain]  view plain  copy
  1. ps -def | grep java  
  2. jenkins   7234  7233 99 11:14 ?        00:00:04 /usr/bin/java -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8082 --ajp13Port=-1  

修改成功。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值