Current location - Quotes Website - Collection of slogans - How to change jenkins port number on Ubuntu
How to change jenkins port number on Ubuntu
Jenkins is a continuous integration tool, which is developed based on Java. In Ubuntu system, the port is occupied when upgrading Jenkins. This problem is solved by modifying Jenkins port number. The following small series will introduce how Ubuntu modified Jenkins port number.

The port number is 8080 and another program uses 8080. Modify the port number to prevent jenkins from occupying port 8080.

By examining the /etc/init.d/jenkins script, we found that there are actually two steps to be completed:

1. Modify the check_tcp_port command of the do_start function and change the port number from 8080 to 8082.

#

# Function to start daemon/service

#

do_start()

{

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

mkdir ` dirname $ PID file `"/ dev/null 2 " & amp; 1 || true

chown $ JENKINS _ USER ` dirname $ pidfile '

# Return

# 0 If the daemon is already started

# 1 (if the daemon is already running)

# 2 If the daemon fails to start

ARGS-run & amp& amp return 1

# Verify that jenkins port is not used and winstone has not exited.

# Even for BindException

check _ TCP _ PORT " HTTP " " $ HTTP _ PORT " " 8082 " | | return 1

# If var MAXOPENFILES is enabled in /etc/default/jenkins, set the maximum number of open files to.

# Appropriate value

if[-n " $ max open files "]; then

[ "$VERBOSE "! = No]&; & ampecho sets the maximum number of open files to max open files.

ulimit-n$max open files

The ship does not bear the loading fee.

#-The user in the daemon does not prepare environment variables such as HOME, user, LOGNAME or USERNAME.

# So now let Sue do it for us.

$ SU-l $ Jenkins _ user-shell =/bin/bash-c "$ daemon $ daemon _ args-$ Java $ Java _ args-jar $ Jenkins _ WAR $ Jenkins _ARGS" || return 2

}

2. Modify the /etc/default/jenkins file and change the port 8080 to 8082.

Then restart jenkins and check:

ps -def | grep java

Jenkins 7234 7233 9911:14? 00:00:04/usr/bin/Java-jar/usr/share/Jenkins/Jenkins . war-webroot =/var/cache/Jenkins/war-http port = 8082-ajp 13 port =- 1

Modification succeeded.

The above is the introduction of Ubuntu's method of changing Jenkins port number. It only takes two steps to change the port number of Jenkins without occupying port 8080.