See imflyn Jenkins+Gradle+Python for an automated package for Android
JenkinsContinuous integration is an open source software project. It is a Continuous integration tool based on Java. It is used to monitor continuous repeated work, and aims to provide an open and easy to use software platform, making continuous integration of software possible. The content of this article is to automate the packaging of Android projects through Jenkins.
Environment: MAC+Java1.8 software: Jenkins2.104+Git2.14.3Copy the code
1. Install Jenkins
1. Download the installation package
Download the Mac version from the official website.
After downloading successfully, double click jenkins-2.104.pkg to install directly. Once the installation is complete, make sure JAVA_HOME is configured in the environment variable, switch to the Jenkins installation directory and run the following command:
java -jar jenkins.war
Copy the code
The default Jenkins port is 8080. To change the Jenkins port number, run the following command
java -jar jenkins.war --ajp13Port=-1 --httpPort=9090
Copy the code
After the startup is complete, type in your browser
http://localhost:9090
Copy the code
For the first time, you need to fill in the password. The password is displayed in the path on the web page. Open the text copy password to the input box and click the continue button.
2. Install the plug-in
Management plug-ins in system administration
There is no indication that plug-ins need to download their own. Hpi plug-in files. You need to download two plugins (git.hpi, gradle.hpi) from Jenkins’ official website. Search for Git and Gradle.
Configure Jenkins
1. Configure The Android environment variables
System Administration -> System Settings, select environment variables in global Properties
2. Configure the JDK and Git
The global tool configuration page is displayed
3. The configuration Gradle
Create a project
1. Create
2. Configure parameterized Build Process
Parameters allow you to prompt users for one or more inputs that will be passed into a build. For example, you might have a project that runs tests on demand by allowing users to upload a zip file with binaries to be tested. This could be done by adding a File Parameter here. Or you might have a project that releases some software, and you want users to enter release notes that will be uploaded along with the software. This could be done by adding a Multi-line String Parameter here. Each parameter has a Name and some sort of Value, depending on the parameter type. These name-value pairs will be exported as environment variables when the build starts, allowing subsequent parts of the build configuration (such as build steps) to access those values, e.g. by using the ${PARAMETER_NAME} syntax (or %PARAMETER_NAME% on Windows). This also implies that each parameter defined here should have a unique Name.
Here’s the official explanation. This article names these added parameters “Build parameters.” The build parameter acts as a global variable for the component task and can be of different types, such as Boolean or String. You can pass these parameters in when you start a component task and reference them in the task as ${PARAMETER_NAME} or %PARAMETER_NAME%.
For example, if you want to start a task with the option to pull code from different branches, create a construction parameter of type Choice called Branch. The optional parameter is the Branch name in your Git repository. For example: master, sprint1, sprint2. Of course, you can also create the channel name or environment name that the channel APK needs to package.
3. Configure the Git repository address
4. Build the configuration