Jenkins use experience to talk about one (step by step to build Jenkins environment)

Source: Internet
Author: User

Jenkins experience to talk about 1 (step by step to build a Jenkins environment)
In the company has been using Jenkins software for some time, took a lot of detours, but also accumulated some experience, can share with you.

Let's build a Jenkins environment together. First choice you need to install good jre/jdk and Tomcat. Since this is not the focus of this article, the installation process is skipped.

The server operating system I experimented with was a 64-bit version of CentOS 5.4, with a JDK version of 64-bit 1.6.0 installed with a tomcat version of 7.0.14.
Digression, in order to solve the possible outofmemoryerror:permgen space problem, need to modify the $tomcat_home/bin/catalina.sh file, add a sentence
Java_opts= "-xms512m-xmx768m-xx:maxnewsize=256m-xx:maxpermsize=128m"

Download the latest version of the war package at the Jenkins Official website (http://jenkins-ci.org/). Copy to the $TOMCAT _home/webapps (no decompression), delete the other directory under WebApps (of course, you can not start Jenkins without TOMCAT, because he has embedded jetty).
Now we create a directory that holds all the Jenkins data, such as/jenkins. Add environment variable Jenkins_home to/etc/profile to point to this path.
Export Jenkins_home=/jenkins

Now we can start the $TOMCAT _home/bin/startup.sh to start the Jenkins, but so every time it starts too much trouble, we make it into a service to start.
Create a Jenkins file under/etc/init.d/

Vi/etc/init.d/jenkins

The

content is as follows, if you want to start with a specified user, modify the Jenkins_user=root value, but remember to change the/jenkins and the Tomcat Directory access permissions. Other environment variables such as Java_home and Tomcat_home are modified according to your actual JDK and TOMCAT installation directory.

#!/bin/sh # Startup script for the Jenkins Continuous Integration Server # (via Jakarta Tomcat Java servlets and JSP ser ver) # chkconfig:-Description:jakarta Tomcat Java servlets and JSP server # processname:tomcat # pidfile:/V Ar/run/tomcat.pid #!/bin/sh # Startup script for the Jenkins Continuous Integration Server # (via Jakarta Tomcat Java S Ervlets and JSP server) # Chkconfig:-Description:jakarta Tomcat Java servlets and JSP server # Processname:t
Omcat # Pidfile:/var/run/tomcat.pid # Set Tomcat environment. Jenkins_user=root lockfile=/var/lock/jenkins export path=/usr/local/bin: $PATH export Home=/jenkins export JAVA_HOME=/ USR/LOCAL/JDK1.6.0_25 Export Jenkins_basedir=/jenkins export tomcat_home=/usr/local/tomcat-7.0.14 export CATALINA_ pid= $JENKINS _basedir/jenkins-tomcat.pid Export catalina_opts= "-djenkins_home= $JENKINS _basedir/jenkins-home- Xmx512m-djava.awt.headless=true "[f $TOMCAT _home/bin/catalina.sh] | | Exit 0 Export path= $PATH:/usr/bin:/usr/local/bin # How we were called.
        Case "in Start" # Start daemon. Echo-n "Starting Tomcat:" Su-p-s/bin/sh $JENKINS _user-c "$TOMCAT _home/bin/catalina.sh start" retval=
        $?
  echo [$RETVAL = 0] && touch $LOCKFILE;;
        Stop) # Stop daemons. Echo-n "shutting down Tomcat:" Su-p-s/bin/sh $JENKINS _user-c "$TOMCAT _home/bin/catalina.sh Stop" RET
        Val=$?
  echo [$RETVAL = 0] && rm-f $LOCKFILE;;
  Restart) $ stop $ start;;
  Condrestart) [e $LOCKFILE] && $ restart;;
  status) status Tomcat;; *) echo "Usage: $ {Start|stop|restart|status}" Exit 1 Esac Exit 0

Install the following command to start the Jenkins Service (start and stop Jenkins also use the service command).
chmod a+x/etc/init.d/jenkins
Chkconfig Jenkins on
Service Jenkins Start

Now access to this server http://172.16.12.80:8080/jenkins/can see that Jenkins has been started.

We are going to install a Nginx on this server to do the reverse proxy, for convenience, I choose to use the RPM package installation method:

$ wget http://nginx.org/packages/rhel/5/x86_64/RPMS/nginx-1.0.9-1.el5.ngx.x86_64.rpm
$ RPM-IVH nginx-1.0.9-1.el5.ngx.x86_64.rpm

Create a new profile/etc/nginx/conf.d/jenkins.conf the contents are as follows (the two lines that are commented out are print logs and are not normally opened):

server {
    listen       ;
    server_name  ci.abc.com;
    #access_log/var/log/jenkins_access_log main;
    #error_log  /var/log/jenkins_error_log  debug_http;
    Client_max_body_size 60M;
    Client_body_buffer_size 512k;
    Location/{
        proxy_pass      http://localhost:8080;
        Proxy_redirect off  ;
        Proxy_set_header Host $host;
        Proxy_set_header x-real-ip $remote _addr;
        Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for
    }
}

Now start Nginx.

Service Nginx Start

Let's modify the local Hosts file (C:\Windows\System32\drivers\etc\hosts) to add:

172.16.12.80 ci.abc.com

This time we enter http://ci.abc.com/jenkins in the browser to see the page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.