title: Why does Jenkins shell file copy not work as expected (does not overwrite existing files)
body: <p>I have a step in a Jenkins pipeline to copy some source files to the workspace. </p>
  
  <pre><code>stage('Copy Files') {
    script {
      echo 'Staging files'
      sh "cp -ar /home/dev/src/ ${env.WORKSPACE}"
    }
  }
  </code></pre>
  
  <p>Yet, when I rerun the build it uses the old code. The only solution is to delete the workspace prior to the copy. In a normal Linux file system a copy will overwrite the destination. Why does Jenkins behave differently--i.e., old files are not overwritten? From the syntax it seems like it is just running a shell command, so why does this not have the expected behavior?</p>