Linux -- Automated Deployment with Jenkins

Jenkins is an independent open source software project. It is a continuous integration tool developed based on Java to monitor continuous and repetitive work. It aims to provide an open and easy-to-use software platform to make continuous software integration possible. Formerly Hudson is an extensible continuous integration engine. Can be used to automate various tasks such as building, testing and deploying software. Jenkins can be installed via the native system package Docker, or even run standalone from any machine where the Java Runtime Environment is installed.

Mainly used:

  1. Continuously and automatically build/test software projects such as CruiseControl and DamageControl.
  2. Monitor some scheduled tasks.

Preparation before installation

CentOS7

After installing 2.0, you need to install jdk1.8 and above (there is no reference to configure the jdk configuration Java environment )

rpm installation package address

1. Installation

1. Install the rpm package

2.Jenkins配置jdk

vi /etc/rc.d/init.d/jenkins

3. Modify the default port of Jenkins

The default JENKINS_PORT of Jenkins is 8080, which conflicts with the default port of Tomcat

vi /etc/sysconfig/jenkins

4. Start the jenkins service

service jenkins start

2. Visit Jenkins

Directly access the corresponding port, such as: 192.168.3.198:8090

Jenkins starts successfully! It comes with a Jetty server, and we do the rest in the browser.

When you start Jenkins for the first time, for security reasons, Jenkins will automatically generate a random password. Pay attention to the password path output by the console, copy and paste the password

Enter the installation interface, if the default installation is performed, Jenkins will automatically configure common plug-ins such as Maven and git. Finally, create an administrator user to complete the installation.

3. Configure Jenkins

Make global tool configuration

After logging in to Jenkins with the management account, before using it for the first time, you need to go to "System Management" -> "Global Tool Configuration":

Configure JDK:

Configure Maven (I choose automatic installation, Jenkins will automatically download and install Maven):

Fourth, the deployment project

On the Jenkins home page, select "Create a new task", enter the project name, and select "Build a maven project":

If there is no "Create a Maven project" option when creating the project.

You need to install the Maven project plugin: ''Maven Integration plugin'

"System Settings" -> "Manage Plugins" -> "Optional Plugins" Then search for keywords in the filter input box on the right: Maven Integration Plugin, install it directly

Project configuration

1. Source code management

Enter the configuration page, select Subversion for source code management, and fill in the source code address.

If password is required, add username/password in Credentials

2. Build the trigger

Build triggers specify the conditions that trigger a build. It is recommended to use the simplest configuration "Poll SCM", which means that the repository is checked regularly and a new commit is found to trigger the build

Indicates a check every two minutes.

3.Build

The default Root POM is pom.xml

4. Run

After packaging, you can fill in shell commands in Pre Steps and Post Steps, and start and stop directly with scripts

5. Configure email address

Send an email notification when there is an error in the project deployment, separated by "," when there are multiple email addresses

After saving, you can perform an automated build (maven dependency package download is slow, change the Maven configuration, and change it to domestic mirror/private server).

Click a build task to deploy the project yourself, and you can see the detailed console output in Console Output for easy troubleshooting.

Guess you like

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