如何在詹金斯的多分支管道中通过ssh发布 [英] How to publish over ssh in multibranch pipeline in jenkins

查看:418
本文介绍了如何在詹金斯的多分支管道中通过ssh发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有根目录下带有Jenkinsfile的Maven springboot项目.我已经在jenkins文件中编写了阶段来构建jar文件,并且工作正常.下一阶段是``部署'',我必须将jar文件移动到Linux服务器并在其中运行它.有人可以在jenkinsfile阶段帮助我如何将jar文件从Jenkins服务器移动到另一台服务器并在该服务器上运行.

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.您可以使用SSH上发布插件并获取管道语法的语法

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.您只需使用scp命令即可在计算机之间传输文件

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做同样的事情

3.curl to do the same

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

您想使用哪一种:)

这篇关于如何在詹金斯的多分支管道中通过ssh发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆