Jenkins uploads the tgz package to the remote server for execution and the jenkinstgz package for upload

Source: Internet
Author: User

Jenkins uploads the tgz package to the remote server for execution and the jenkinstgz package for upload

Jenkins is a useful automated build tool for continuous integration of development and testing.

When developing a system, we often need to package it into the test environment for execution. This step is fixed but cumbersome, especially during testing, the bug may have to be changed and re-packaged and thrown into the test environment. In particular, if N bugs have been changed in a short time, they need to be packaged N times.

If we use jenkins for continuous integration, we will set something once and for all, and then directly build and run it after fixing the bug, which is convenient and quick.

The jenkins installation is also very simple. It is a war package and can be directly used:

java -jar jenkins.war

I still like to use tomcat for war management.

During installation, it is best to set the global environment variables of jenkins. Some of the items about jenkins will be put in this directory. Of course, you can also specify the environment variables of jenkins when starting tomcat, you only need. sh, add the following export, and define the path according to your needs.

# OS specific support.  $var _must_ be set to either true or false.export JENKINS_HOME="/data/apps/jenkins"

After the installation is complete, download some plug-ins, such as ssh, git, and svn, as needed.

Configure and write global plug-ins, such as maven, git, and jdk.

Here is the maven setting file address:

JDK configuration (jdk needs to be installed by yourself ):

Git configuration (you need to install git on the server ):

Maven configuration (maven needs to be installed on the server ):

Then configure the system settings:

Here, several builds are retained as needed:

Ssh remote plug-in publish over ssh

Above:

Passphrase is the password of your remote machine
Path to key is the address of your local private key
Key: local private Key

Note that the private key is a local machine rather than a remote machine.

Generally, you only need to paste the private key here or specify the address.

Remote Directory is the root Directory on the Remote machine. At that time, everything is uploaded remotely to this Directory. If it is not configured, It is the default home Directory (for example, root is/root)

Ssh key generation:

Ssh-keygen-t rsa-C "your name"

Public Key copy:

ssh-copy-id  IP

Create a project:

Based on your needs

I used git for testing, provided that I have configured my public key to git.

Note: An error may be reported here:

Warning: Permanently added '10.0.4.147' (RSA) to the list of known hosts

If the configuration is correct, you only need to add the following two lines to the end of the vi/etc/ssh/ssh_config file:

StrictHostKeyChecking noUserKnownHostsFile /dev/null

Here, you can configure the cron expression to indicate when to automatically check the build project:

Here let jekins package:

Here we use ssh to publish to a remote machine, decompress it, and execute:

Click build now after the configuration is complete:

Check whether the process on the remote machine exists:

The entire process is as follows.

The java project used for testing is as follows:

The project is the tgz package compiled with assemb, and start. sh is the MainClass started.

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.