Advertisement
GrueMaster

Untitled

Jul 8th, 2019
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.04 KB | None | 0 0
  1. // requires ssh pipeline steps plugin
  2.  
  3. //preliminary schtuff
  4. def destDir = '/srv/buildfiles'
  5. def remote = [:]
  6. remote.name = '<servername>'
  7. remote.host = '<FQDN or IP address>'
  8. remote.allowAnyHosts = true
  9.  
  10.  
  11. // Get the date and git sha tag
  12. def date = sh (script:'date +%Y%m%d', returnStdout: true).trim()
  13. def gitTag = sh (script: 'git describe --always --match "v[0-9].*"', returnStdout: true).trim()
  14.  
  15. //append these to your destdir root path
  16. destDir += "/${date}-${gitTag}"
  17.  
  18. //publish it
  19. stage("Publish Bitstream"){
  20.     if (fileExists("build_${gbsName}/megh_sira_DCPRCA10_${gbsName}.gbs")) {
  21.         withCredentials([sshUserPrivateKey(credentialsId: '<your credentials key goes here>', keyFileVariable: 'userKey', passphraseVariable: 'userPass', usernameVariable: 'userName')]) {
  22.              remote.user = userName
  23.              remote.identityFile = userKey
  24.              sshCommand remote: remote, command: "mkdir -p ${destDir}"
  25.              sshPut remote: remote, from:"<file or directory to publish>", into: destDir
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement