欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > Jenkins使用Publish Over SSH插件远程部署程序到阿里云服务器

Jenkins使用Publish Over SSH插件远程部署程序到阿里云服务器

2024/10/24 22:22:55 来源:https://blog.csdn.net/Joe192/article/details/141321550  浏览:    关键词:Jenkins使用Publish Over SSH插件远程部署程序到阿里云服务器

前言

使用Jenkins远程构建springboot服务到阿里云上,Jenkins版本:Version 2.462.1

1、准备

在可选插件中,搜索Maven Integration ,Gitlab和 Publish Over SSH 三个插件:
在这里插入图片描述
如果需要多用户管理那就安装:Role-based Authorization Strategy插件即可

2、配置Publish Over SSH服务

在这里插入图片描述
如果这块出现问题,请查看下面问题解决方案

3、项目脚本配置

在这里插入图片描述
脚本:

source /etc/profile
project=springboot-rest.jar
dir=/home/project/app/if [ ! -d "$dir" ]; thenmkdir -p "$dir"
fiapi_id=$(ps -ef | grep 9099 | grep -v "grep" | grep "$dir$project" | awk '{print $2}')
echo $api_idfor id in $api_id
dokill -9 $id
echo "killed $id"
donenohup java -Xms1G -Xmx1G -XX:PermSize=32m -XX:MaxPermSize=512m -jar "$dir$project" --spring.profiles.active=prod --server.port=9099 > $dir/nohup.out 2>&1 &

基本到这就大功告成了。
如果在构建中出现问题,可以勾选这个打印详细的远程问题进行定位解决,
在这里插入图片描述

问题解决方案

问题1:jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [aly-ssh]. Message [Algorithm negotiation fail: algorithmName=“server_host_key” jschProposal=“ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256” serverProposal=“ssh-rsa,ssh-dss”]]

解决方案:
在启动时增加配置参数即可:
1 如果是war包直接启动的:直接在java -jar 后面添加这两个参数

-Djsch.client_pubkey=ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256  
-Djsch.server_host_key=ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256

2 如果是exe启动的(windows的msi安装版是在服务启动的),那就找到jenkins目录下的jenkins.xml,找到下的标签jvm参数后
在这里插入图片描述
参考资料:
https://blog.csdn.net/t0404/article/details/136206576
https://developer.aliyun.com/article/1312890
https://blog.csdn.net/suo082407128/article/details/116239286
https://blog.csdn.net/m0_58943936/article/details/135368557
https://blog.csdn.net/JasonWeng/article/details/113574958
https://my.oschina.net/mmuuyyuu/blog/5544039
https://www.cnblogs.com/jxxiaocao/p/12691289.html

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com