jenkins configuration ftp release

We in Jenkins publish our compiled firmware to the product library. There are many upload methods. Here are two methods of FTP:

1. GUI plug-in configuration

Description: This plug-in can publish the built product (for example: Jar) to FTP.

Official description: Publish Over FTP Plugin

installation steps:

System Management→Manage Plugins→Optional Plugins→Artifact Uploaders→Publish Over FTP Plugin

System Settings

FTP Server Name: Give it to yourself, call it whatever you like.

Hostname: host IP or domain name

Username: ftp login username

Password: ftp password

Remote Directory: Remote root directory (recommended setting: /)

Figure 1 Basic system setting interface

Click Advanced above Test Configuration, as shown below:

Port: Port (ask the administrator if you don’t know)

Timeout (ms): timeout time (milliseconds)

Use active data mode: (unchecked) The default option uses PASV (passive mode), checked to use PORT (active mode)

Don’t make nested dirs: Do not create subordinate directories (see the help for details)

Figure 2 System settings advanced interface

There is also an advanced option in the lower right corner of the picture above. If you are interested, you can try it yourself. Tip: You need to save first, refresh the page, and configure. Otherwise, there is an option that cannot be selected.

Project configuration

Enablement steps:

Post-build action→Add post-build action→Send build artifacts over FTP

FTP Server Name: Choose a name for the configuration you configured in the system settings.

Transfer Set Source files: Files that need to be uploaded (note: relative to the path of the workspace, it can be a single file or a directory)

Remove prefix: Remove the directory (only directories in Transfer Set Source files can be specified)

Remote directory: Remote directory (fill it in according to your needs, because I am testing here, so I am lazy and just use /)

Figure 3 Basic project setting interface

Click Advanced behind Remote directory, as shown below

Exclude files: Exclude files (useful when you transfer directories, use wildcards, for example: **/*.log,**/*.tmp,.git/)

Pattern separator: separator (configure the separator for Exclude files and Source files. If you change it here, the above content also needs to be changed)

No default excludes: Disable default exclusion rules (see help for details)

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

Flatten files: Only create files on ftp, no directories (except remote directories)

Remote directory is a date format: The remote directory creates a folder with date (the date format needs to be configured in the Remote directory). 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

Clean remote: All files in the remote directory will be deleted before uploading (a painful lesson. During the test, I used the operation team’s ftp, and then accidentally deleted their data, which made me do data recovery. .)

ASCII mode: File transfer method, generally not selected by default.

Figure 4 Project settings advanced interface

Okay, these are the commonly used options, you can fiddle with the other options yourself. This plug-in is suitable for people with strong hands-on skills.

2. Pipeline script publishing

1. Install the Publish Over FTP plug-in

First, install the Publish Over FTP plug-in in Manage Jenkins → Manage Plugins.

2. Configure FTP Server

After that, you need to add FTP Server in the Publish Over FTP area of the Manage Jenkins → Configure System page, where Name is It will be used in the Pipeline script later.

3. Pipeline script

Finally, the upload operation is performed through the ftpPublisher method in the script.

Regarding how to write the script, you can select the ftpPublisher: Send build artifacts over FTP example to automatically generate the script on the Pipeline Syntax page.

The following points need to be noted:

  • The masterNodeName and paramPublish parameters are required. I don’t know why these two parameters are not included in the automatically generated script;
  • The publishers → configName value is the FTP Server Name set in the second step;
  • remoteDirectory specifies the remote directory for uploading
  • sourceFiles specifies the files to be uploaded
  • removePrefix is set to the file prefix that needs to be filtered out
    • In the following example, all files in the OctopusSoa/OctopusApi/target/ directory will be automatically uploaded to the server directory of the FTP server.
    • If removePrefix is empty, it will be uploaded to the server/OctopusSoa/OctopusApi/target/ directory.
stage('Upload') {
    {steps
        ftpPublisher alwaysPublishFromMaster: false,
                        continueOnError: false,
                        failOnError: false,
                        masterNodeName: '',
                        paramPublish: null,
                        publishers: [[
                            configName: 'SOA-D',
                            transfers: [[
                                asciiMode: false,
                                cleanRemote: false,
                                excludes: '',
                                flatten: false,
                                makeEmptyDirs: false,
                                noDefaultExcludes: false,
                                patternSeparator: '[, ] + ',
                                remoteDirectory: 'server',
                                remoteDirectorySDF: false,
                                removePrefix: 'OctopusSoa/OctopusApi/target',
                                sourceFiles: 'OctopusSoa/OctopusApi/target/*.jar'
                            ]],
                            usePromotionTimestamp: false,
                            useWorkspaceInPromotion: false,
                            verbose: false
                        ]]
    }
}

Source: https://www.cnblogs.com/zz0412/p/jenkins_jj_04.html

Source: https://www.liujiajia.me/2020/3/26/jenkins-upload-to-ftp-server-with-pipeline

  END 

Recommended reading

【1】Detailed sharing of the basics of development and use of jetson nano

【2】Linux development coredump file analysis practical sharing

【3】How does the program in the CPU run? Must read

【4】Cartographer environment establishment and mapping test

[5] Comparison of simple factory mode, factory mode, and abstract factory mode in design patterns [Habayashi-kun] All the original information of this public account has been organized into a directory. You can get it by replying to [Resources].

The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. Java Skill TreeHomepageOverview 138625 people are learning the system