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 ? 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') May 5 '20 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
    Aug 20 at 3:40
2

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.