(5), use Jenkins to automatically pull the code and upload the server

Install the necessary plugins: Publish Over SSH, Maven Integration plugin

1. Install the plugin Publish overSSH


2. Install the plugin MavenIntegration plugin


3. JDK and Maven environment variable settings

JDK configuration


If the jdk is already installed, it can be directly referenced. (Enter in cmd: java -verbose, at the end of the command line, the path to the jdk installation is displayed)

 

Maven configuration

If Maven is already installed, just referencing it directly. (Enter: mvn -version in cmd, the command line shows the path of Manven installation); if Maven is not installed, please refer to "2. Maven3.5.3 Installation and Configuration"

4. Configure server parameters


SSH Server Name: Select the SSH server that has been added in the system settings.
Transfer Set Source files: The files that need to be uploaded to the application server (Note: relative to the path of the workspace, you can fill in multiple, separated by commas by default)
Remove prefix: Remove the prefix (Only directories in Transfer Set Source files can be specified)
Remote directory: An optional destination folder. If the folder does not exist, the folder will be created.
Exec command: The command to be executed on the remote server. The script commands here are executed after the remote SSH transfer is executed.
Advanced options:
Exclude files: Excluded files (useful when transferring directories, use wildcards, for example: /*.log,/*.tmp,*.txt/ )
Pattern separator: Separator (delimiter for configuring Transfer Set Source files)
No default excludes: Suppress default exclusion rules
Make empty dirs: This option changes the default behavior of the plugin. The default behavior is to match whether the file exists, and if so, create a directory to store it. Checking this option will directly create a directory to store the files, even if it is an empty directory.
Flatten files: Only upload files, do not create directories (except remote directories)
Exec timeout (ms): Timeout for running scripts (ms)
Exec in pty: Simulate a terminal to execute scripts
Add Transfer Set: Add a transfer configuration
Remote directory is a date format: The remote directory creates a folder with a date (the date format needs to be configured in the Remotedirectory). For the specific format, refer to the following table:

Remote directory

Directories created

‘qa-approved/’yyyyMMddHHmmss

qa-approved/20101107154555

‘builds/’yyyy/MM/dd/’build-${BUILD_NUMBER}’

builds/2010/11/07/build-456 (if the build was number 456)

yyyy_MM/’build’-EEE-d-HHmmss

2010_11/build-Sun-7-154555

yyyy-MM-dd_HH-mm-ss

2010-11-07_15-45-55

5. Configure SVN account

1) Enter the configuration directory

2) Configure account information

6. Create a task

Note: The option to "build a maven project" is only available if the Maven Integration plugin is installed

7. Configuration

1)   General

2) Source code management

3) Build the trigger

4) Build environment

5)   Pre Steps

6)   Build

Goals and options填写:cleaninstall -Pqa  -Dmaven.test.skip=true

Pom.xml path and configuration:

7)   Post Steps



8) Build Settings

9) Post-build operations

If you want to send an email to notify the members of the group after the upgrade, you can configure "Editable Email Notification" here.

8. Questions

1) Solve the problem of Jenkins needs to know where your Maven is installed when configuring Jenkins

When configuring a project in Jenkins, the local Maven is installed, but it still prompts Jenkins needs to know where your Maven is installed. As shown in the following figure:

Solution:

For a higher version of Jenkins, such as version 2.58:

Return to Panel-System Management-Global Tool Configuration-Maven-Maven Installation, set MAVEN_HOME, and be careful not to check "Automatic Installation".

 

2) / and \ are inconsistent, pay attention to the configuration with "/"


3) Do not have Chinese in the tomcat path to avoid unrecognized


4) Fewer dependencies

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325896076&siteId=291194637
Recommended