Answers: <p>Please try with double <code>//</code> before <code>var</code> in <code>remoteDirectory: '/var/www/sockets'</code>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-10-23T18:04:50.643Z
Answers: 2020-10-23T21:11:24.023Z
Answers: 2020-10-23T21:11:24.023Z
Answers: user24433
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2020-05-05T19:46:21.480Z
Comments: can you try **/.env ?
Comments: karthikeayan
Comments: CC BY-SA 4.0
Comments: 2020-05-05T21:50:40.867Z
Comments: @karthikeayan yes. But it's not working. when i rename .env to development.env then it works fine (sourceFiles: '**/*.env')
Comments: Hasan Hafiz Pasha
Comments: CC BY-SA 4.0
Comments: 2021-08-20T03:40:21.717Z
Comments: The path is relative directory, Means, generally it creates files at remote home directoy, on remote server i.e. at ~/var/www/sockets
Comments: Krishna
Tags: <jenkins><jenkins-pipeline>
Title: Jenkins transferring file using publish over SSH plugin but file not show in remote development server
UserDisplayName: Hasan Hafiz Pasha
ThreadText: # 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 [username_0-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'`.
  
  
  ---
  
  