当前位置:Gxlcms > linux教程 > 在Ubuntu上更改jenkins端口号的方法

在Ubuntu上更改jenkins端口号的方法

时间:2021-07-01 10:21:17 帮助过:5人阅读

  Jenkins是一种持续集成工具,基于Java开发,在Ubuntu系统中,升级Jenkins的时候出现端口被占用的问题,通过修改Jenkins端口号来解决这个问题,下面小编就给大家介绍下Ubuntu如何修改Jenkins端口号吧。

 在Ubuntu上更改jenkins端口号的方法

  端口号是8080,另一个程序用到了8080,修改端口号不让jenkins占用8080端口。

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

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

  #

  # Function that starts the daemon/service

  #

  do_start()

  {

  # the default location is /var/run/jenkins/jenkins.pid but the parent directory needs to be created

  mkdir `dirname $PIDFILE` 》 /dev/null 2》&1 || true

  chown $JENKINS_USER `dirname $PIDFILE`

  # Return

  # 0 if daemon has been started

  # 1 if daemon was already running

  # 2 if daemon could not be started

  $DAEMON $DAEMON_ARGS --running && return 1

  # Verify that the jenkins port is not already in use, winstone does not exit

  # even for BindException

  check_tcp_port “http” “$HTTP_PORT” “8082” || return 1

  # If the var MAXOPENFILES is enabled in /etc/default/jenkins then set the max open files to the

  # proper value

  if [ -n “$MAXOPENFILES” ]; then

  [ “$VERBOSE” != no ] && echo Setting up max open files limit to $MAXOPENFILES

  ulimit -n $MAXOPENFILES

  fi

  # --user in daemon doesn‘t prepare environment variables like HOME, USER, LOGNAME or USERNAME,

  # so we let su do so for us now

  $SU -l $JENKINS_USER --shell=/bin/bash -c “$DAEMON $DAEMON_ARGS -- $JAVA $JAVA_ARGS -jar $JENKINS_WAR $JENKINS_ARGS” || return 2

  }

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

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

  ps -def | grep java

  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

  修改成功。

  上面就是Ubuntu更改Jenkins端口号的方法介绍了,只需两步就可将Jenkins的端口号进行修改,不会占用端口8080。

人气教程排行