Build Jenkins Portable environment under Linux environment

Source: Internet
Author: User

1: Background

Project Area: Android.

Project requirements: Establish a website for the product Manager (hereinafter referred to as PM) to configure the service plug-in for the APK, package the package (including: APK, Documentation, demo, etc.) to the manufacturer and record the package-out information.

Project design Simple text description:

Using PHP as a server-side development language, nginx servers, the MySQL database to store data, to Jenkins as a continuous building aids.

The simple schema is as follows:

The packaging flowchart is as follows:

2:jenkins Introduction

Jenkins is an open source software project designed to provide an open and easy-to-use software platform that makes continuous software integration possible. Plainly, it is essentially a Web project that provides the ability to build packaged projects, pull projects from SVN, execute scripts, and so on. Download Jenkins from official website to get a Jenkins.war file, the. war file format is the file format that will self-extract when the project is published in the Tomcat service.

installation method: JDK 1.4 or later is required: General recommendation The second, more stable.

1: You can extract the file via Java-jar Jenkins.war, then you can enter it in the browser: locathost:8080 Open the Jenkins home page.

2: Move the Jenkins.war file to the WebApps directory of Tomcat and the run Tomcat,.war file will be automatically extracted to the Jenkins folder. Visit: Localhost:8080/jenkins to open the Jenkins home page.

3: Environment Construction and configuration

Machines for Linux systems. The environment involved in the construction process is as follows:

1:JDK environment, need more than 1.4.

2: Install Tomcat

3: Install Jenkins, download the Jenkins.war package, copy to the Tomcat WebApps directory.

4: Install and configure the Android environment to provide various Android-related commands in the packaging script.

5: Install ant, which provides an ant script to perform ant function (Android apk package).

6: Configure SVN.

After the building needs to ensure portability, that is, replace the machine later, copy a folder to the new machine, execute a script. For this there is the following structure of the directory (where the directory name can be self-determined, the red part is key):

1: Put all the files into the/data/jenkins directory of the Linux root directory and mount the/data directory on a separate hard drive

2: All environment variable configurations need to be put into the/DATA/JENKINS/.BASHRC script, the. BASHRC script needs to be configured in the Boot execution list

The 3:jenkins project will have a working directory that is primarily used to save build records, SVN-pulled project files, and so on. The working file name is typically:. Jenkins, which needs to be configured in the/data/jenkins directory, which can be viewed in the Jenkins home page, with hints on how to configure it.

3.1: Install Java JDK

Download the Java JDK version 1.6 or more of the compressed package , unzip it into the/data/jenkins/java_xxx directory, and then configure the environment variables, add code in the/DATA/JENKINS/.BASHRC file.

1:export java_home=/data/jenkins/java_xxxx, the directory is mainly used for classpath and PATH environment variables, but also for some third-party software use, such as: Tomcat.

2: Configuration classpath, mainly used for class search, and import,package related. Because of the complexity of this configuration, Sun helps users to run Java projects without being configured.

Export classpath=.: $JAVA _home/dt.jar: $JAVA _home/tool.jar;

3: Configuration path,path Specifies directories where commands can be run directly by the user, such as configuring the bin directory of the JDK to run java-version directly.

Export path= $JAVA _home/bin: $JAVA _home/lib: $PATH;

After the configuration is complete, run java-version to see if it is configured correctly.

3.2: Install Tomcat

Download the Tomcat 7.0 version of the compressed package and unzip it into the/data/jenkins/tomcat_xxx directory. Perform tomcat_xxx/bin/startup.sh, and then visit localhost:8080 to see if it is working properly.

After normal operation, you need to add to boot, create a new Tomcat script in Etc/init.d, execute the/DATA/JENKINS/.BASHRC script first, and then start the startup.sh in Tomcat, please query the code.

3.3: Install Jenkins

Download the jenkins.war,copy to the/tomcat_xxx/webapps directory, and then configure the environment variables to increase in/DATA/JENKINS/.BASHRC.

Export Jenkins_home=/data/jenkins/.jenkins, the main configuration of the JENKINS data file directory, which stores each build record, log and SVN pull files.

Then open localhost:8080/jenkins/configure, configure the workspace directory (the file that holds the SVN pull) and build the spatial directory,

3.4: Install Android Environment

Download Android sdk,copy to/data/jenkins/directory, name ANDROID-SDK, and then configure the environment variable to add in/DATA/JENKINS/.BASHRC:

Export ANDROID_SDK_HOME=/DATA/JENKINS/ANDROID-SDK, which primarily specifies the ANDROID root directory.

Export Proguard_home=/data/jenkins/android-sdk/tools/proguard, which is primarily used for confusion in packaging.

3.5: Install Ant

Download the ant compression Pack, unzip it into/DATA/JENKINS/ANT-XXXX, then configure the environment variable to add in the/DATA/JENKINS/.BASHRC:

Export Path=/data/jenkins/ant-xxx/bin: $PATH

3.6: Set SVN

Jenkins usually comes with SVN, opens the Jenkins home page, Localhost:8080/jenkins, creates a new project, sets the SVN address in the SVN column, clicks Authorization, enters the username and password, and saves it. It does not require SVN authorization to be packaged in the future, enabling automatic packaging.

After the setup is successful, you also need to go to the/data/jenkins/directory, execute SVN info plus your working directory, authorize, and save forever.

4:jenkins API

Jenkins provides an interface-based approach, as well as an API that can be invoked by other platforms. In my project, the server sends commands through the Jenkins API to build a project for Jenkins, delete items, get project status, and more.

API View Url:https://wiki.jenkins-ci.org/display/jenkins/remote+access+api.

5: Precautions

1: All environment configuration is in DATA/JENKINS/.BASHRC,. BASHRC need to boot, can be put into etc/init.d/tomcat execution.

2:android SDK installation needs to see if it matches the Linux system, if the 64-bit system has 32 bits, there will be an ant package exception error, the lack of system-level commands, of course, can also be a one-time patch installation.

The commands referenced in the 3:ant script need to correspond to the directory of the Android SDK, the directory of the JDK. Otherwise, the command cannot be found.

6:yy

This is the first time to write a blog, feel really good, very helpful to themselves. Good place to write, welcome to the views of the visitors.

Build Jenkins Portable environment under Linux environment

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.