问题
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.
回答1:
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 :)
来源:https://stackoverflow.com/questions/50376212/how-to-publish-over-ssh-in-multibranch-pipeline-in-jenkins