jenkins使用Send build artifacts over SSH发布jar包目录配置

本测试用ruoyi-plus的代码。

1 [GitLab 自动触发 Jenkins 构建_jenkins构建触发器没有build when a change is pushed to git-CSDN博客](https://blog.csdn.net/wangyiyungw/article/details/81776972)

2 [jenkins使用Send build artifacts over SSH遇到的坑-CSDN博客](https://blog.csdn.net/goxingman/article/details/129749284)

多层级配置ssh远程传送构建物:

1 在ssh配置帐号密码时要配置一个默认的远程目录

2 配置Source files:jenkins工作空间后的打包项目目录:即$SERVER_NAME后面的部分:

```

如:JAR_PATH=/var/lib/jenkins/workspace/$SERVER_NAME/ruoyi-admin/target

ruoyi-admin/target/slcsp-2supply.jar

```

3 配置目录:目标机器的目录:Remote directory[

](http://192.168.0.243:8081/job/slcsp-2supply/configure# "Help for feature: Remote directory")

如:slcsp/slcsp-2supply

则会把jar包发送给默认远程目录+Remote directory

配置后可以看日志

```

#!/bin/sh

#进入jar所在路径

cd /usr/local/slcsp/slcsp-2supply

#查看运行记录,并停止进程

BUILD_ID=DONTKILLME #后台执行

pid=(ps -ef\|grep slcsp-2supply.jar\|grep -v grep \| awk '{print 2}')

function stop(){

if [ -n "$pid" ]

then

echo "pid进程 :$pid"

kill -9 $pid

else

echo "进程没有启动"

fi

}

stop

sleep 5s

#启动运行程序

nohup /usr/local/java/jdk-17.0.11/bin/java -Xms512m -Xmx1024m -jar /usr/local/slcsp/slcsp-2supply/slcsp-2supply.jar --spring.profiles.active=dev /dev/null 2>&1 &

```

日志:

```

Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts

SSH: Connecting from host [TestServer-1]

SSH: Connecting with configuration [slcsp-dev-239] ...

SSH: Creating session: username [root], hostname [192.168.0.239], port [22]

SSH: Connecting session ...

SSH: Connected

SSH: Opening SFTP channel ...

SSH: SFTP channel open

SSH: Connecting SFTP channel ...

SSH: Connected

SSH: cd [/usr/local]

SSH: OK

SSH: cd [/usr/local]

SSH: OK

SSH: cd [slcsp/slcsp-2supply]

SSH: OK

SSH: put [slcsp-2supply.jar]

SSH: Opening exec channel ...

SSH: EXEC: channel open

SSH: EXEC: STDOUT/STDERR from command

```

问题:

复制代码
jenkins远程ssh启动程序后日志报错:
复制代码
SSH: Disconnecting configuration [slcsp-dev-239] ...
ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after 120,006 ms]
Build step 'Send build artifacts over SSH' changed build result to UNSTABLE
Finished: UNSTABLE

解决:

方案一:延长 SSH 执行超时时间

在 Jenkins 配置中调整 SSH 步骤的超时设置:

登录 Jenkins;

进入你的项目配置页面;

找到 Send build artifacts over SSH 步骤;

修改 Exec command timeout (ms) 设置,例如设为 300000(5 分钟);

默认是 120000(2 分钟)

相关推荐
牛奶咖啡1311 小时前
CI/CD——使用Jenkins实现自动化部署与持续集成之jenkins插件与凭据配置
ci/cd·jenkins·jenkins必备插件安装·jenkins全局工具配置·jenkins的凭据配置·jenkins自动化部署流程·jenkinsgitlab集成
摇滚侠11 小时前
DSL 学习 ElasticSearch 主要就是学习 DSL 查询语言
学习·elasticsearch·jenkins
九成宫1 天前
Git 与远程仓库实操记录:克隆、配置、分支推送与问题排查
笔记·git·ssh
庚昀◟2 天前
腾讯云 CVM + Docker + Jenkins + GitLab CI/CD 全流程指南(python、flask实现简单计算器)
python·ci/cd·docker·flask·jenkins
牛奶咖啡132 天前
CI/CD——使用Jenkins实现自动化部署与持续集成
ci/cd·jenkins·jenkins是什么?有啥用·jenkins有哪些适用场景·jenkins的优缺点·jenkins的安装部署·jenkins安装必备环境
测试那点事儿3 天前
第10章 零基础接口自动化到 Jenkins 持续集成【定时监控与邮件告警完整落地】
ci/cd·自动化·jenkins
a***72893 天前
Java进阶(ElasticSearch的安装与使用)
java·elasticsearch·jenkins
魔极客3 天前
第十二节:龙晰 AnolisOS-23.4-x86_64.qcow2 虚拟机的网络配置方式及 ssh 连接
网络·ssh·php
摇滚侠4 天前
黑马 Elasticsearch 全套教程,黑马旅游网案例
大数据·elasticsearch·jenkins
身如柳絮随风扬4 天前
使用 Docker 部署 Jenkins 并实现自动化部署 —— 从零到一的 CI/CD 实践指南
docker·自动化·jenkins