Jenkins

Jenkins mainly implements multiple platforms to update the code together, as long as the developer submits the code, he will update it. It is convenient for developers to check for leaks.

Personal understanding of continuous integration: In order to solve the problem of low quality submission of program code and bugs in the original system caused by the submitted content, the version is automatically compiled on time or on demand, and automated testing is performed.

Baidu's definition of continuous integration: Continuous integration is a software development practice, that is, team development members integrate their work frequently, usually each member integrates at least once a day, which means that multiple integrations may occur per day. Each integration is verified through automated builds (including compilation, release, and automated testing) to find integration errors as quickly as possible. Many teams find that this process can greatly reduce integration problems, allowing teams to develop cohesive software faster.

For details, please refer to: http://blog.51cto.com/linuxg/1790033

http://blog.51cto.com/linuxg/1791141

 

Jenkins is a free and open source continuous integration server. It is written in JAVA. It can be used to automate various tasks related to software development such as build testing and deployment. It supports many version control systems like git, SVN, mercurial, etc.

In this tutorial, we will install Jenkins Automation Server on CentOS 7 server. We will also set up Nginx as a reverse proxy for Jenkins.

 

 

Environment: centos7.0


Before installing any packages, it is recommended that you update packages and repositories with the following commands.
After updating the system with yum -y update

, continue to install JAVA. Install JAVA 8
Jenkins supports OpenJDK and Oracle JAVA, in this tutorial, we will install the latest version of OpenJDK into the server. Run the following command to install OpenJDK on your server.
yum install java-1.8.0-openjdk

java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)

You also need to check if The JAVA_HOME environment variable is set. Run the following command the same
echo $JAVA_HOME

If you get empty or blank output, you need to manually set the JAVA_HOME variable, editor edit the .bash_profile file
vi ~/.bash_profile

Now add the following line at the end of the file.
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/
export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8. 0.131-3.b12.el7_3.x86_64/jre

source the file using the following command.
source ~/.bash_profile

echo $JAVA_HOME command to check if environment variable is set.
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/Installing



Jenkins Jenkins


can be installed directly by adding the repository and importing the GPG key. Add the Jenkins repository to the system by running the following command.

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

Import the GPG key by running the following command.
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

After the import is successful, you can install Jenkins by running the following command.
yum -y install jenkins

Jenkins is now installed on your server. All required packages are now installed. The installer also created a new user jenkins to run the process. You can proceed to start the server.



Start Jenkins

systemctl start jenkins
systemctl status jenkins


can use Apache or Nginx web server to create a reverse proxy for the application instead of accessing the application on port 8080.
 In this tutorial, we will use nginx as a reverse proxy for the application. Now, nginx will run behind the nginx proxy server
 
vi /usr/local/nginx/conf/vhost/jenkins.conf

upstream jenkins{
    server 127.0.0.1:8080;
}

server{
    listen      80;
    server_name ci.yourdomain.com;

    access_log  /var/log/nginx/jenkins.access.log;
    error_log   /var/log/nginx/jenkins.error.log;

    proxy_buffers 16 64k;
    proxy_buffer_size 128k;

    location / {
        proxy_pass  http://jenkins;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        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;
        proxy_set_header X-Forwarded-Proto https;
    }

}



systemctl start nginx
to make Nginx start automatically
systemctl enable nginx to



configure firewall and SELinux
On your server running a firewall, you need to allow port 8080 and standard HTTP through the firewall port. Run the following command to add firewall rules to allow ports 8080 and 80.

firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-service=http --permanent

Run the following command to reload the firewall zone:
firewall-cmd - -reload


configure SELinux for nginx proxy configuration by running the following command.
setsebool httpd_can_network_connect 1 -P


http://ci.yourdomain.com or http://ip:8080


cat /var/lib/jenkins/secrets/initialAdminPassword

On the next interface it will install the plugin

to create an admin for the Jenkins admin dashboard member user
User: adminPassword
: adminAddress
: qq Email

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324704184&siteId=291194637