In the past 2 days, I setup a CI development environment in Linux:
Git + Jenkins + Maven (Nexus) + Tomcat
I write the steps down to keep memo.
Pre-installed Software:
1. JAVA:I Use jdk1.8.0_25
Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
jdk-8u25-linux-i586.rpm
Install the JDK, and add the environment variable:
Vi/etc/profile
Java_home=/usr/java/jdk1.8.0_25
Export jre_home=/usr/java/jdk1.8.0_25
Export Jre_bin=/usr/java/jdk1.8.0_25/bin
Export classpath= $JRE _home/lib: $CLASSPATH
Export path= $JRE _home/bin: $PATH
Source/etc/profile
Verify:in the terminal, run: java-version and could see the version
2. Maven:
http://maven.apache.org/download.cgi
Apache-maven-3.2.3-bin.tar.gz
Extract the tar file and move it to/usr/local:
TAR-XVF apache-maven-3.2.3-bin.tar.gz
MV apache-maven-3.2.3/usr/local/apache-maven-3.2.3
Add environment variable:
Vi/etc/profile
maven_home=/usr/local/apache-maven-3.2.3
Export Maven_home
Export Path=${path}:${maven_home}/bin
Source/etc/profile
Verify:in the terminal, run: mvn-v and could see the version
3. Git
IMPORTANT: In Redhat 6, and your use of yum install git could only install 1.7.1 version, but that Versi On are out date, and have some problem for authentication, so if you install the Git 1.7.1, you need to uninstall it, using< c9> rpm-e git
And maybe ask you uninstall the Perl-git something, anyway, you need to rpm-e git per-get to remove them all.
Finally, I find a document about what to install latest version of Git:
http://tecadmin.net/install-git-1-9-on-centos-rhel/
Step 1:install Required Packages
Yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-extutils-makemaker
Step 2:download and Compile Git Source
https://www.kernel.org/pub/software/scm/git/git-1.9.4.tar.gz # tar Xzf git-1.9.4.tar.gz
Step 3. Check Git Version
One completion of above steps, you has successfully install Git in your system. Let use following command to check git version
# git--version
git version 1.9.4
4. Jenkins:
http://pkg.jenkins-ci.org/redhat-stable/
jenkins-1.580.1-1.1.noarch.rpm
Install the RPM, and then startup Jenkins by:
Service Jenkins Start
and visit:
http://localhost:8080
You should see the Jenkins UI.
Chmod-r 777/var/lib/jenkins
5. Tomcat:
http://tomcat.apache.org/download-70.cgi
Apache-tomcat-7.0.57.tar.gz
Extract the tar file and move it to/usr/local:
TAR-XVF apache-tomcat-7.0.57.tar.gz
MV apache-tomcat-7.0.57/usr/local/apache-tomcat-7.0.57
Make sure that the permission to change the folder, otherwise, and the permission to 777
Chmod-r 777/usr/local/apache-tomcat-7.0.57
Modify/usr/local/apache-tomcat-7.0.57/conf/tomcat-users.xml:
<role rolename= "Manager-gui"/>
<role rolename= "Manager-script"/>
<user username= "Tomcat" password= "Tomcat" roles= "Manager-gui,
Manager-script "/>
Modify/usr/local/apache-tomcat-7.0.57/conf/server.xml
Change the port to 8888.
<connector port= "8888" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
<connector executor= "Tomcatthreadpool"
port= "8888" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
Verify:in/usr/local/apache-tomcat-7.0.57/bin
[Email protected] bin]# startup.sh
Using catalina_base:/usr/local/apache-tomcat-7.0.57
Using Catalina_home:/usr/local/apache-tomcat-7.0.57
Using Catalina_tmpdir:/usr/local/apache-tomcat-7.0.57/temp
Using Jre_home:/usr/java/jre1.8.0_25
Using CLASSPATH:/usr/local/apache-tomcat-7.0.57/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.57/bin/ Tomcat-juli.jar
Tomcat started.
Configuration:
First make sure you has pushed all the "code to Jazzhub" or GitHub, in this case, and I use Jazzhub.
Step 1:
Add necessary plugins. By default, Jenkins 1.580.1-1.1 have installed all the necessary plugins (Git, Marven, deploy to container), if not, you sho Uld install them first from "Manage Jenkins", "Manage Plugins" menu.
After the, make sure, if you "New Item" and you should see "Build a Maven project" option:
Step 2:config System:
To config some system level options used in Jenkins. From "Manage Jenkins", "Config System"
ADD the tools location in Global properties-Tool Locations
In the Git section, fill the "Path to git executeable" as "/usr/local/git/bin/git" where we installed Git.
Create a new project:
In the Jenkins Web UI, click on "New Item", create a Maven project and named "Restdeploy", then config the project:
1.Git section:input the Git repository Url:https://hub.jazz.net/git/wangpbj/restdeploy with the Username/password.
IMPORTANT: Here I had a problem with git 1.7.1, and reportedunable to find remote helper for ' https ' , It proved that, the Git version matter, after I changed to Git 1.9.4, the problem disappeared. It would automatically connect to the repository, and would report error if have problem.
In the ' Build Triggers ' section, I select Poll SCM every mins.
In the ' Build ' section, set ' Root POM ' as ' restdeploy/pom.xml ', ' goals and options ' as ' clean install ', click ' Advanced ' m ENU, to check ' use private Maven repository ', in the ' Settings file ' select ' Settings file in filesystem ', and fill the fi Le path "settings.xml".
inportant: By default, my settings file locates In/root/.m2/settings.xml, but it reports can not find the file, so I had to copy th e settings.xml file to /var/lib/jenkins/jobs/restdeploy/workspace It seems Jenkins search the folder as root fol Der Jenkins would use the "/var/lib/jenkins/.m2/" as its own Maven repository.
Because I want to use mirror to Maven Central site, I setup a Nexus server locally, it could is much quick, and could hold Our own plugins/libs (such as DB2 JDBC driver) to gkfx within teams. The content of the settings.xml:
<?xml version= "1.0" encoding= "UTF-8"?
<settings xmlns= " http://maven.apache.org/SETTINGS/1.0.0 "
xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance "
xsi: schemalocation= "http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd";
<plugingroups></plugingroups>
<proxies></proxies>
< Servers>
<server>
<id>nexus-snapshots</id>
< Username>admin</username>
<password>admin123 </password>
</server>
<server>
<id>tomcat</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<name>internal Nexus Repository</name>
<url> http://9.123.149.131:8081/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles></profiles>
</settings>
In the Post-build actions sections, select "Deploy war/ear to a container", Context Path:/restdeploy, select "Tomcat 7.x" As container, and set "Tomcat"/"Tomcat" as username and password. Tomcat url:http://localhost:8888
Everytime Restart the Linux, need to do the following steps:
1.Startup Nexus:
Cd/root/nexus-2.10.0-02/bin
Export Run_as_user=root
./nexus Start
2. Startup Tomcat:
Cd/usr/local/apache-tomcat-7.0.57/bin
startup.sh
3. Open port 8888 for Tomcat and 4000 for Nomachine for remote control:
Cd/sbin
Iptables-i input-p TCP--dport 8888-j ACCEPT
Iptables-i output-p TCP--sport 8888-j ACCEPT
4. Startup Jenkins:
Service Jenkins Start
5. Startup SSH:
Service sshd Start
Test:
Everytime Push code to Jazzhub:https://hub.jazz.net/git/wangpbj/restdeploy
After mins (I-Set the 1 min/poll before, but server was only a out of date desktop machine, it was fully occupied and Ver Y slow ...), the staging server would show the latest version show:
http://9.123.149.131:8888/ Restdeploy
TODOs if I have time:
1. Write a shell script to execute the startup process.
2. Auto push to Bluemix.
3. ADD test Framework.
4. ADD code Inspect framework.
How to setup CI development environment in Linux