0

I have a running a Jenkins job by Jenkins pipeline. i wants to send an environmental (.env) file from my local system to my server using Publish Over SSH Plugin.

Here is my Jenkins snippet:

stage('Pull In Development') {
        when { branch 'development' }
        steps {
            script {
                sshPublisher(publishers: [
                    sshPublisherDesc(configName: 'developmment-server',
                        transfers: [
                            sshTransfer(
                                cleanRemote: false,
                                excludes: '',
                                execCommand: '',
                                execTimeout: 120000,
                                flatten: false,
                                makeEmptyDirs: false,
                                noDefaultExcludes: false,
                                patternSeparator: '[, ]+',
                                remoteDirectory: '/var/www/sockets',
                                remoteDirectorySDF: false,
                                removePrefix: '',
                                sourceFiles: '**/*.env'
                            )
                        ],
                        usePromotionTimestamp: false,
                        useWorkspaceInPromotion: false,
                        verbose: false
                    )]
                )
            }
        }
    }

Then after transferring, it shows 1 file transferred.

SSH: Connecting from host [pasha-pc]
SSH: Connecting with configuration [stage-server-v1] ...
SSH: Disconnecting configuration [stage-server-v1] ...
SSH: Transferred 1 file(s)

But when i enter the server and go to /var/www/sockets no .env file here. So am I make any mistake on SSH code.

NB: .env on git ignored file

3
  • can you try **/.env ? Commented May 5, 2020 at 19:46
  • @karthikeayan yes. But it's not working. when i rename .env to development.env then it works fine (sourceFiles: '*/.env') Commented May 5, 2020 at 21:50
  • The path is relative directory, Means, generally it creates files at remote home directoy, on remote server i.e. at ~/var/www/sockets
    – Krishna
    Commented Aug 20, 2021 at 3:40

1 Answer 1

3

Please try with double // before var in remoteDirectory: '/var/www/sockets'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.