Jenkins file upload to a remote server (Publish Over SSH)

1. Install the Publish Over SSH plugin

System management → Manage plugins → Optional plugins → Artifact Uploaders → Publish Over SSH

 See if it is installed

2. Publish over SSH public configuration (system configuration)

 System Management → System Configuration → Publish Over SSH

Common configuration instructions:

Passphrase: password (key password, if you set it)

Path to key: The path of the key file (private key)

Key: Copy the private key to this box

Disable exec: prohibit running commands

 

Private configuration instructions:

SSH Server Name: the name of the logo (whatever you choose, generally related to the root server, which will be used below)

Hostname: the host name or ip address that needs to connect to ssh (ip recommended)

Username: Username

Remote Directory: Remote directory (that is, the uploaded directory)

Click on advanced options

Advanced options for private configuration:

Use password authentication, or use a different key: You can replace the public configuration (selected and expanded is the public configuration, so it has good scalability)

Passphrase: Password (You can replace the publicly configured password, but you must select the Use password ... check box here)

Port: Port (default 22)

Timeout (ms): The timeout time (milliseconds) can be the default

Disable exec: prohibit running commands

Test Configuration

3. Project configuration

XX project-> configuration-> add construction steps

 Basic configuration instructions:

Name: corresponds to the private configuration SSH Server Name in Publish Over SSH

Transfer Set

Source files: files that need to be uploaded (relative to the path of the work area. You can fill in more than one, the default is, separated, which  **/* means all files and directories under the job directory of this job.)

Remove prefix This operation is for the source files directory above, and will remove the matching directory. Usually left blank

Remote directory: Remote server directory (such as my test here, then add public configuration (system configuration)-> private configuration-> Remote Directory and finally / xcdata / test /)

advanced

Advanced configuration instructions:

Exclude files: Excluded files (useful when you transfer a directory, use wildcards, for example: / .log, / .tmp, .git /)

Pattern separator: Separator (Configure the separator of Transfer Set Source files. If you change it here, the above content also needs to be changed)

No default excludes: disable the default exclusion rules (see help for specific)

Make empty dirs: This option will change the default behavior of the plugin. The default behavior is to match whether the file exists, and if it exists, create a directory to store it. Selecting this option will directly create a directory to store files, even if it is an empty directory. (Personal understanding)

Flatten files: only upload files, do not create directories (except remote directories)

Remote directory is a date format: The remote directory establishes a folder with a date (the date format needs to be configured in the Remote directory)

Exec timeout (ms): timeout time for running steps (ms)

Exec in pty: Simulate a terminal to execute the steps

Add Transfer Set: add a configuration

Pit description:

1.Transfer Set Source files配置

The pit that occurred (SSH: Transferred 0 file (s)):

 the reason

Transfer Set Source files here use the path relative to the work area, for example, the working directory of your jenkins is / xcdata / docker-jenkins / jenkins / jenkins_home / workspace / tj, then this directory can only be relative to this directory (Do not fill in the absolute path, write a relative path),

For example, if you want to go to the remote, fill in ** / *, if it is a single directory (such as /xcdata/docker-jenkins/jenkins/jenkins_home/workspace/tj/test/app.jar), fill in / test / *

2.Exception when publishing, exception message错误

 There are two reasons for this error:

1. The disk space is full, just clear the disk space

df -h (view disk space)

2. No permission

The user password in the Publish Over SSH configuration does not have permission to create files

Guess you like

Origin www.cnblogs.com/jxxiaocao/p/12691289.html