Issue with ftpPublisher not creating directories on FTP Server

Hello,

I am encountering an issue with the ftpPublisher plugin, where it fails to create directories on the FTP server. According to the inline help and the plugin’s documentation, the following behaviour is expected:

Remote directory

If specified, the files will be transfered below this directory (which is relative to the Remote Directory specified in the Host Configuration for this server).
If the directory does not exist it will be created.

I have configured the FTP Server in the Publish over FTP section under Manage => System and named it Dev-Symbols. The connectivity test using the Test Configuration option was successful.

I verified with WinSCP that I can manually create a directory on the FTP server using the same user account Jenkins is configured to use.

Could someone please advise on what I might be doing wrong? How can I configure Jenkins to create directories on the FTP server automatically? Any assistance would be greatly appreciated.

For context, my FTP server is running on IIS 8.5.

Below is the test pipeline I’m using:

def myPublishSymbols() {
    ftpPublisher(
        alwaysPublishFromMaster: true,
        continueOnError: false,
        failOnError: false,
        masterNodeName: '',
        paramPublish: null,
        publishers: [[
            configName: 'Dev-Symbols',
            transfers: [[
                asciiMode: false,
                cleanRemote: false,
                excludes: '',
                flatten: false,
                makeEmptyDirs: false,
                noDefaultExcludes: false,
                patternSeparator: '[, ]+',
                remoteDirectory: "'${env.P4_CHANGELIST}'",
                remoteDirectorySDF: true,
                //removePrefix: Binaries.replace("\\", "/"),
                //sourceFiles: '${Binaries.replace("\\", "/")}*.pdb'
                removePrefix: "",
                sourceFiles: '*.pdb'
            ]],
            usePromotionTimestamp: false,
            useWorkspaceInPromotion: false, 
            verbose: true
        ]]
    )
}

pipeline {
    agent {
        node {
            label 'windows-agent'
        }
    }
    environment {
        ROOT = "${WORKSPACE}\\workspace"
        P4_CHANGELIST = "clTEST"
    }
    stages {
        stage('Create content') {
            steps {
                bat "if not exist \"${ROOT}\\myProject\\Binaries\\Win64\" mkdir \"${ROOT}\\myProject\\Binaries\\Win64\""
                writeFile file: "${ROOT}\\myProject\\Binaries\\Win64\\file.pdb", text: 'This is a test file from Jenkins.'
            }
        }
        stage('Upload to SymbolsServer') {
            steps {
                dir("${ROOT}/myProject/Binaries/Win64/") {
                    echo "Uploading files."
                    myPublishSymbols()
                }
            }
        }
    }
    // post { cleanup { cleanWs() } }
}

Here’s the relevant section of the build log:

[Pipeline] {
[Pipeline] echo
Uploading files.
[Pipeline] ftpPublisher
FTP: Connecting from host [ci]
FTP: Connecting with configuration [Dev-Symbols] ...
220 Microsoft FTP Service
FTP: Logging in, command printing disabled
FTP: Logged in, command printing enabled
CWD /DebugSymbols/myProject
250 CWD command successful.
TYPE I
200 Type set to I.
CWD /DebugSymbols/myProject
250 CWD command successful.
CWD clTEST
FTP: Disconnecting configuration [Dev-Symbols] ...
ERROR: Exception when publishing, exception message [Exception when changing to FTP directory [clTEST]]
[Pipeline] }

Jenkins setup:

Jenkins: 2.468
OS: Linux - 5.10.0-31-amd64
Java: 17.0.11 - Debian (OpenJDK 64-Bit Server VM)
---
...
publish-over:0.22
publish-over-ftp:1.17
publish-over-ssh:1.25
...

Thank you in advance for your help.

Hello and welcome to this community, @CTxP4. :wave:

Could the issue you’re encountering with the ftpPublisher plugin failing to create directories on the FTP server be due to the makeEmptyDirs parameter being set to false?

Thanks for your response, @poddingue. I’ve just tried setting makeEmptyDirs to true, but unfortunately, it still doesn’t create directories on the FTP server. I’ve switched to using cifsPublisher, which works perfectly. However, it would be great if this issue could be resolved.

1 Like

I was about to suggest you open an issue on the plugin’s JIRA, but it looks like it is not very active.

Would you like to have a look at the code and try to solve it?

I’d like to, but unfortunately, I’m not familiar enough with Java to properly read or write the code. For now, I’ll stick with cifsPublisher. Thanks for your support and involvement.

I have created Loading....
The formatting there got messed somehow. :confused: