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: [
                                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

  • can you try **/.env ? – karthikeayan May 5 '20 at 19:46
  • @karthikeayan yes. But it's not working. when i rename .env to development.env then it works fine (sourceFiles: '*/.env') – Hasan Hafiz Pasha May 5 '20 at 21:50

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, privacy policy and cookie policy

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