<p>Please try with double <code>//</code> before <code>var</code> in <code>remoteDirectory: '/var/www/sockets'</code>.</p>

CC BY-SA 4.0
2020-10-23T18:04:50.643Z
2020-10-23T21:11:24.023Z
2020-10-23T21:11:24.023Z
user24433
<p>I have a running a Jenkins job by Jenkins pipeline. i wants to send an environmental (<code>.env</code>) file from my local system to my server using Publish Over SSH Plugin.</p>
<p>Here is my Jenkins snippet:</p>
<pre><code>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
                    )]
                )
            }
        }
    }
</code></pre>
<p>Then after transferring, it shows 1 file transferred.</p>
<pre><code>SSH: Connecting from host [pasha-pc]
SSH: Connecting with configuration [stage-server-v1] ...
SSH: Disconnecting configuration [stage-server-v1] ...
SSH: Transferred 1 file(s)
</code></pre>
<p>But when i enter the server and go to <code>/var/www/sockets</code> no <code>.env</code> file here. So am I make any mistake on SSH code.</p>
<p>NB: <code>.env</code> on git ignored file</p>

CC BY-SA 4.0
2020-05-05T19:46:21.480Z
can you try **/.env ?
karthikeayan
CC BY-SA 4.0
2020-05-05T21:50:40.867Z
@karthikeayan yes. But it's not working. when i rename .env to development.env then it works fine (sourceFiles: '**/*.env')
Hasan Hafiz Pasha
CC BY-SA 4.0
2021-08-20T03:40:21.717Z
The path is relative directory, Means, generally it creates files at remote home directoy, on remote server i.e. at ~/var/www/sockets
Krishna
<jenkins><jenkins-pipeline>
Jenkins transferring file using publish over SSH plugin but file not show in remote development server
Hasan Hafiz Pasha
# Jenkins transferring file using publish over SSH plugin but file not show in remote development server

(Asked by: username_0 on 2020-05-05)

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

**Tags:** jenkins, jenkins-pipeline

> **Comments:**
> **username_1**: can you try **/.env ?  
> **username_0**: @username_1 yes. But it's not working. when i rename .env to development.env then it works fine (sourceFiles: '**/*.env')  
> **username_2**: The path is relative directory, Means, generally it creates files at remote home directoy, on remote server i.e. at ~/var/www/sockets  

---

## 1 answers

### Answer by username_3 on 2020-10-23. Score: 3

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


---

