Jenkins continuous integration SVN repository project

1 Overview

Jenkins is an open source continuous integration tool written in Java language. Its predecessor is Hudson. It can be used to automatically compile, test and release projects, which greatly reduces the tedious and repetitive work between teams, thereby speeding up Delivery progress of the entire project.

jenkins官方wiki:https://wiki.jenkins.io/display/JENKINS/Use+Jenkins

2 Install Jenkins 

2.1 Install JDK

(1) Installation package: jdk-7u80-linux-x64.rpm

(2) Unzip the installation package

$ rpm -ivh jdk-7-linux-x64.rpm

(3) Environment variable configuration: vi /etc/profile

JAVA_HOME=/usr/java/jdk1.7.0_80

JRE_HOME=/usr/java/jdk1.7.0_80/jre

PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

export JAVA_HOME JRE_HOME PATH CLASSPATH

2.2 Install Maven

(1) Installation package: apache-maven-3.5.2-bin.tar.gz

(2) Unzip the installation package

$ tar -zxvf apache-maven-3.5.2-bin.tar.gz -C /usr/local/

(3) Configure maven environment variables

2.3 Install Jenkins

There are two ways

Method 1: Download the jenkins.war package directly

Two ways to run jenkins.war

(1) Run java -jar jenkins.war through the built-in container of jenkins

(2) Running through a separate tomcat/jboss container

Method 2: Install through yum (here choose to install the stable version)

(1) Import the yum source of Jenkins

$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo

$ sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

(3) yum installation

$ sudo yum install jenkins

The installation can be successful through the above command, and finally installed in the /usr/lib/jenkins directory, the configuration file is: /etc/sysconfig/jenkins

3 Jenkins commands

(1) Start

$ service jenkins start

(2) stop

$ service jenkins stop

(3) Restart

$ service jenkins restart

4 View the Jenkins web management page

(1) The default startup port of jenkins is 8080, which can be set by modifying /etc/sysconfig/jenkins

(2) Query in the browser: 192.168.58.122:8080

5 Jenkins and SVN integration configuration to build a free style project

5.1 Create a new SVN user authentication

5.2 Create a new task

5.3 Specific build configuration

(1) General item configuration

(2) Source code management item configuration

1) The Repository URL specifies the address of the SVN project. The SVN plugin in Jenkins pulls the latest code according to the content change timestamp in the SVN repository by default, but it needs to ensure that the Jenkins server and the server time of the SVN repository are consistent, here you can pass Add the @HEAD parameter after the address to specify that the latest version number is used to pull, so that there is no need to configure the time of the two servers to be the same

(2) Credentials specifies the previously added SVN user

(3) Build trigger configuration

This specifies that project changes are detected from the SVN repository every minute

(4) Click Save and enter the home page to see the newly created job task

 

(5) Modify the content of the files in the SVN project, wait for a minute, and Jenkins will automatically pull the latest code from SVN to build

6 Summary

This article mainly introduces the construction of Jenkins and the project of continuous integration of the SVN repository. For other details of the use of Jenkins, please refer to the official website documentation: https://wiki.jenkins.io/display/JENKINS/Use+Jenkins

Guess you like

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