[Jenkins] to modify the port number at the Ubuntu jenkins

jenkins installation directory: / var / lib / jenkins 
jenkins log directory: /var/log/jenkins/jenkins.log
jenkins default configuration: / etc / default / jenkins
 
By examining /etc/init.d/jenkins script, we discovered that in fact you need to do two steps:
1. Modify do_start function check_tcp_port command, the port number from 8080 into 8082
[plain] 
#                                                                                                                                                                                                                      
# 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  
    be  
  
    # --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. Modify the / etc / default / jenkins file, port 8080 into 8082
 
Then restart jenkins, check:
[plain] 
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  

Guess you like

Origin www.cnblogs.com/chenxiaomeng/p/11412038.html