Use of Jenkins+tomcat+maven+gitlab+shell environment under Linux (Jenkins Automated Deployment)

Source: Internet
Author: User
Tags pack

Jenkins Automation Deployment Goal: Jenkins on point build (also automatically check code changes automatically build) "Project deployment complete." First, install the jenkins1. Download Jenkins

Here I choose is the war package installs Jenkins, simple does not hurt the brain, other blog writes the Jenkins version is very old, does not use the newest, writes a relatively new configuration 2.20 edition.

Official website: https://jenkins.io/index.html

War pack: Http://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.20/jenkins.war

Http://mirrors.tuna.tsinghua.edu.cn/jenkins/war-stable/2.32.3/jenkins.war

2. Installing the JDK Environment

The newest jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html no account registration one, soon

Jdk-8u121-linux-x64.tar.gz
Here Select the Linux64-bit suffix tar.gz copy download link, unzip the configuration environment variable on the server Vim/etc/profile write on the last side

JAVA_HOME=/DATA/JAVA/JDK Directory name #java目录是我创建的, unpack the JDK into the inside, the absolute path to write the decompression location
Classpath= $JAVA _home/lib/
Path= $JAVA _home/bin: $PATH #谨慎, where the path is wrong, you will find that the command has to hit the absolute path to use, sad reminder
Export PATH java_home CLASSPATH

Configuration no problem to complete the save, Source/etc/profile let the configuration of the environment variable to take effect, this time can command java-version see version, is not out of Java version "1.8.0_***", If it is 1.6 what the instructions did not take effect, look at the path of decompression.

3. Install Tomcat

: http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.75/bin/apache-tomcat-7.0.75.tar.gz

What version of this can be, not too old, the old will have loopholes, decompression to complete the test can not be used, the Tomcat directory inside the bin directory,./catalina.sh start, access, can not access the basic is a firewall problem, can appear Tom cat interface can stop, can. catalina.sh Stop, you can also find the process pid,kill-9 PID number, into the WebApps directory to delete all, the previous Jenkins.war copied in, start Tomcat. I use the 8080 Port Access address is http://Public address £ 8080/jenkins

On the server above the Cat/root/.jenkins/secrets/initialadminpassword will appear to let the input password, a string of digital letters, more than one will appear below the interface, drinking saliva, three minutes passed, the next interface appeared

This means that the recommended installation or their own choice, the need for the package behind can be installed, I ordered the first, know with what plug-in point the second can also pack less. The installed plugins are under/root/.jenkins/plugins/.

Directly select Continue as Admin

Start using, click on it will come in

Admin user Login still do not know the password is what, I guess is/root/.jenkins/secrets/initialadminpassword this inside password, HTTP//This place to play ip:8080/jenkins/user/ Admin/configure Change the admin password, you can also point system management, in the inside to find administrative users, click on the top of the screen admin in the bottom to change the password to save.

Second, install Maven (used to build the project)

Website address: http://maven.apache.org/download.cgi

: apache-maven-3.3.9-bin.tar.gz

Configure environment variables: Vim/etc/profile write to the end, I use the 3.3.3 version

Export m2_home=/data/apache-maven-3.3.3
Export m2= $M 2_home/bin
Export path= $M 2: $PATH

Third, install Git

: https://github.com/git/git/releases

Pop, want to download can download, and then compile the installation, Git is mainly used for Jenkins with git command to get our own build Gitlab above code, I yum install git, there is a problem also reported wrong, we must be optimistic about git can use the command absolute path where, Yum installed in the/usr/bin/git, you can try/usr/bin/git--version, whether it is 1.7 version or 2.3 version can be used.

Iv. Configuring Jenkins

Jenkins because of configuration error thousands, one step an error, every day there are surprises, the following configuration is to fill the pits.

1. Add Plugins

Select an optional plugin to filter the search

Choose Direct installation can also, restart after installation can also, with what function to search the installation did not install, not installed on the good, I saw the installed, more than the installation of their own installation of a lot more ...

Many tutorials are loaded with the deploy to Container Plugin, which can send packages from the project HTTP address of the running Tomcat directly to the Project Server directory, Windows I tried to, Linux this thing useless it, Linux server SCP used to be good, the windows on the bread on the past will not write scripts, or shell script simple.

2. Tool configuration

JDK alias name can be anything, path write, write your JDK environment variable configuration path, write wrong will appear error:failed to parse POMs java.io.IOException:Cannot run program*** error

Git address to write is the address of git this command is not the address of the directory, Yum installed the nature is/usr/bin/git, before the Yum installed to write/usr/local/git error can not find git command, in the server a variety of try git no problem, Look at the configuration for Jenkins can not see it, installed several versions of Jenkins, find n long to find should write/usr/local/git/bin/git

After writing the save is good, next system configuration

3. System Configuration

This configuration laborious Dickens, in the error after n times to find the wrong time, in the system provided by the English document accidentally see one of the answers, good long to see one of the sentences, tried to succeed, Ward days!

V. Building PROJECTS

Click New, appear, name casually, choose to build a MAVEN project

Connect git, we are our own gitlab, we need to search for SSH or key on the Gitlab, find an SSH keys, put the Jenkins server's public key on the above, in addition

This adds a Jenkins server root user's private key

Find the Gitlab server's private key can also, estimated because the Gitlab page also put the Gitlab public key, it seems that a pair of public private key can, interested can try.

Choose this here can write script, I write this is equivalent to the script command to remotely execute another script

After writing for a long time, today Jenkins did a migration, perfect the front, the back of the re-fill on

, the following functions are scripted, Jenkins and org do a secret login, on Jenkins can directly use/USR/BIN/SSH [email protected] IP "command to execute"

/bin/bash/dat****/org.sh execute this script on org

Process: Jenkins call git to download the code on the Gitlab to the Jenkins server, MAVEN build into a war package, call SSH run shell script to complete the backup, stop service, clear WebApps, copy War package to Tomcat under the service, say it is very simple ah ...

I groped for a ride, a variety of errors, took two weeks to set up, today moved to another server on a few hours on the finish, after a few months of use, Jenkins is really a tool for automation, write a script a key to get it done

Use of Jenkins+tomcat+maven+gitlab+shell environment under Linux (Jenkins Automated Deployment)

Related Article

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.