0

I have maven springboot project with Jenkinsfile at root. I have written stages in jenkins file to build jar file and it's working fine.Next stage is 'deployment' where i have to move jar file to Linux server and run it there. Could anyone please help me with stage in jenkinsfile how to move jar file from Jenkins server to another server and run it there.

Madhu Sudhan Reddy
  • 607
  • 5
  • 15
  • 22

1 Answers1

3

1.you can use the Publish over SSH plugin and get the syntax for Pipeline syntax

sshPublisher(publishers: [sshPublisherDesc(configName: 'SERVER_to_be_deployed', transfers: [sshTransfer(excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**/target/*.war')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])

2.you can just use a scp command to transfer files across machines

scp [options] username1@source_host:directory1/filename1 username2@destination_host:directory2/filename2

3.curl to do the same

curl -u username:password -T /path/to/file.txt sftp://host.com:22/file.txt

Which one would you like to use :)

rohit thomas
  • 2,302
  • 11
  • 23
  • @Madhu Sudhan Reddy if this helped you in solving your issue please select it as the correct answer so that others, who face this issue will know what needs to be done – rohit thomas May 21 '18 at 04:09