Automatic building of Android projects using Jenkins (3)

Source: Internet
Author: User

Building a Jenkins Project

1. "New Job", fill in the Job name, select "Build Maven 2 or 3 project"->ok. The new success will go to "set", temporarily leave the default values, and then the settings later.

2. Click "Build Now" to display "queued to build", and then in the "Build the process" to meet the # link, click on the link and select "Terminal Output", you will see a failed build record. Of course it will fail, because we have not added code and pom.xml to the project, we have to build it, let the system build the project directory for us, the directory path is <Jenkins_dir>/workspace/<project_name>.

3. Upload the project-dependent package and execute the following command

MVN Install:install-file-dfile=file.jar-dgroupid=group.id-dartifactid=artifact-id-dversion=1.0.0-dpackaging=jar

DgroupId and DartifactId form the coordinates of the jar package in Pom.xml, and the project relies on these two properties for positioning. You can name yourself, if you use your own name, in the pom.xml of the dependence of the need to use their own names. Dfile represents the absolute path of the jar package that needs to be uploaded, and the file is uploaded to Maven's default warehouse location.

4. Add the Android Project code and pom.xml to the project directory, then click "Build Now" and if the code and Pom.xml are correct, the project should be built successfully.

5. Now go back to the settings screen

Because Git Plugin was previously installed, there was one more git in "Source code management", filling in the correct repository URL,Credentials Adding a username and password. Added Additional behaviours, added check out to specific local branch.

"Build the trigger" can choose "Regular Setup" or "SCM", "Regular setup" is built at the specified time interval, "SCM" is to poll git at the specified intervals to build.

"New build pre-steps" can execute some commands before building.

"Root POM" specifies the location of the Pom.xml, "Goal and Options" fill in the build MVN commands and parameters, such as mvn clean package-p dev Surefire-report:report,surefire-report: Report can generate surefire report, but this report's HTML does not have CSS, it is more ugly. You can run MVN site to generate the HTML and CSS for MAVEN Surefire report First, then save it, and then execute the command copy into the report after each build is completed.

"New build after step" can execute some commands after building.

6. "New build after action" can be built after the operation of some operations, if the installation of e-mail Extension plugin, you can send a notification message after the build is complete.

" new built-in action", "customizable Email notification"->advanced setting-> "add trigger" can increase the conditions for triggering a message, and you can use content tokens in the notification message .

Examples of notification messages:

This email is automatically sent by the program, please do not reply directly, thank <br/>, template= "HTML"}<br/>${file, path= "./file.txt"}

More tokens available

${build_log, maxLines, escapehtml}- Displays the final build log.

    • MaxLines – Displays the maximum number of rows that the log displays, with a default of 250 rows.
    • escapehtml -If true, the HTML is formatted. False by default.

${build_log_regex, REGEX, linesbefore, linesafter, maxmatches, Showtruncatedlines, substtext, escapehtml, matchedlinehtmlstyle}- Displays the number of rows in the build log by matching the regular expression.

    • matches the number of rows that match the regular expression. See java.util.regex.Pattern, default "(? i) \b (Error|exception|fatal|fail (ed|ure) |un (defined| Resolved)) \b ".
    • Linesbefore -The line number that is contained before the matching line. The number of rows will match the current other row or linesafter overlap, default 0.
    • Linesafter -The row number that is included after the matching line. The number of rows will match the current other row or linesbefore overlap, default 0.
    • maxmatches -The maximum number of matches, if 0, contains all matches. The default is 0.
    • Showtruncatedlines -If True, contains [... truncated # # # # lines ...] Yes. The default is true.
    • Substtext -If not empty, insert this part of the text into the message instead of the entire line. The default is empty.
    • escapehtml -If true, the HTML is formatted. False by default.
    • Matchedlinehtmlstyle -if not NULL, the output HTML. The number of matches will change to <b style= "Your-style-value" > HTML escaped matched line </b> format. The default is empty.

${build_number}- Displays the number of the current build.

${build_status}- Displays the status of the current build (failure, success, and so on)

${build_url}- Displays the URL address of the current build.

${changes, showpaths, format, Pathformat}- shows the changes since the last build.

    • showpaths – If True, displays the modified address of the submission. False by default.
    • format – traverse the commit information, a string containing%x, where%a represents the author,%d represents the date,%m represents the message,%p represents the path, and%r represents the version. Note that not all versions of the system support%d and%r. If the specified showpaths is ignored . Default "[%a]%m\n".
    • Pathformat -a string containing "%p" that indicates how to print the string.

${changes_since_last_success, reverse, format, showpaths,Changesformat , Pathformat}- shows the changes since the last successful build.

    • Reverse -marks the latest build at the top. False by default.
    • format -iterates through the build information, a string containing%x, where%c is the change for all,%n is the build number. The default "changes for Build #%n\n%c\n".
    • showpaths, changesformat, pathformat – define showpaths, format, respectively, as ${changes} and pathformat parameters.

${changes_since_last_unstable, reverse, format, showpaths, Changesformat, pathformat}- displays the changes after the last shaky or successful build.

    • Reverse -marks the latest build at the top. False by default.
    • format -iterates through the build information, a string containing%x, where%c is the change for all,%n is the build number. The default "changes for Build #%n\n%c\n".
    • showpaths, changesformat, pathformat -Define showpaths as ${changes} respectively, The format and pathformat parameters.

${env, var}– displays an environment variable.

    • var – Displays the name of the environment variable. If blank, all is displayed and the default is empty.

${failed_tests}- If there are failed tests, display these failed unit test information.

${jenkins_url}- Displays the address of the JENKINS server. (You can change it on the "System Configuration" page).

${hudson_url}- not recommended, please use $jenkins_url

${project_name}- Displays the name of the project.

${project_url}- Displays the URL of the project.

${svn_revision}- Displays the version number of SVN.

${cause}- shows who, through what channels, triggered this build.

${jelly_script, template}- customizes the message content from a JELLY script template. There are two types of templates to configure: HTML and text. You can replace it by customizing it under $jenkins_home/email-templates. When using auto-defined templates, the name of the "template" parameter does not contain ". Jelly".

    • Templates-template name, default "HTML".

${file, path}- contains the contents of a specified file

    • Path-file path, note that is the relative path of the workspace directory.

${test_counts, var}- Displays the number of tests.

    • var – Default "Total".
      • Total-the number of all tests.
      • Fail-the number of failed tests.
      • Skip-Skips the number of tests.

Resources:

"1" http://www.juvenxu.com/2011/05/18/hudson-email-ext/

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.