目录
问题1:fatal: 远端意外挂断了 fatal: 过早的文件结束符(EOF) fatal: index-pack 失败
问题2:ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [-1]]
当出现没有正常结束命令,但是服务已经正常启动的情况,应该将 shell 文件手动的进行执行一下,看看脚本到底是哪里出现了问题
环境准备:
1. 安装git
不想麻烦的话直接:( 1.1~1.6 的步骤就不用走了)
yum -y install git
1.1 git 安装环境
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
1,2 下载 git 压缩包
官网地址: https://github.com/git/git/releases
1.3 上传,解压缩,进入到解压文件夹
解压缩:
unzip git-2.29.2.zip
1.4 编译git源码
make prefix=/usr/local/git all
1.5 安装
make prefix=/usr/local/git install
1.6 移除之前安装的git
yum -y remove git
1.7 修改配置文件
vim /etc/profile
重新载入配置文件
source /etc/profile
1.8 检测
1.9 添加配置信息
增加git缓冲区的大小,缓存区小的情况下,有可能在下载大的项目的时候出现异常退出,出现下面的情况(也有可能是网络不稳定造成)
fatal: 过早的文件结束符(EOF)
warning: unable to unlink '(null)': 错误的地址
org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
git config --global http.postBuffer 524288000
设置用户名称
git config --global user.name "yang_zzu"
设置邮箱
git config --global user.email "13849187852@163.com"
查看配置信息
git config --list
生成秘钥,指定生成的秘钥名称,和之前其他的秘钥进行区分,否则的会将之前的秘钥覆盖掉,导致之前其他地方的秘钥认证无法使用
ssh-keygen -t rsa -C "13849187852@163.com" -f /root/.ssh/github_rsa
将生成的 github_rsa.pub 文件内容,添加到,github 上面的
修改 /root/.ssh/config 文件,没有的话进行创建
Host github.com
HostName github.com
User 13849187852@163.com
IdentityFile /root/.ssh/github_rsa
Host 192.168.44.10
HostName 192.168.44.10
User root
IdentityFile /root/.ssh/id_rsa
Host github.com 地址
HostName github.com 名称
User 13849187852@163.com github的账号
IdentityFile /root/.ssh/github_rsa 对应的 github 上面的私钥
验证是否正常的连接
ssh -T git@github.com
2. maven 安装
下载地址: https://maven.apache.org/download.cgi
2.1 下载,上传,解压
2.2 修改配置文件
vim /etc/profile
2.3 修改 setting.xml 文件
本地仓库的存储位置
<localRepository>/app/apache-maven-3.6.3/maven-download-jar</localRepository>
远程仓库的地址
<!-- 使用阿里的maven -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
将文件复制到 , 用户家目录下的 .m2 文件内,因为在执行 mvn 打包的时候使用的是这里的 setting.xml 文件
如果不进行复制,则在进行 打包的时候,会报错
cp settings.xml /root/.m2/
安装Jenkins
下载地址: http://mirrors.ustc.edu.cn/jenkins/war/ 这个下载的比较快
官网地址: http://mirrors.jenkins.io/war/ 官网下载的太慢了
java -jar jenkins.war --httpPort=8080
输出的内容是 激活的密码
浏览器访问8080端口 http://192.168.44.10:8080/
输入上面的的激活密码, 或者到指定的文件夹内进行复制
添加插件
需要安装 publish over ssh 插件,否则后面打完jar 包后,无法和 服务器通信执行 shell 脚本
直接点击 直接安装即可
Jenkins配置
1. 系统配置
2. 全局工具设置
Jenkins 添加服务
restart.sh 文件的内容, 里面的一些内容,要根据项目的情况,进行一些更改
#!/bin/bash
#停止之前的服务
echo "Stop Procedure : first-web-1.0-SNAPSHOT.jar "
pid=`ps -ef | grep java | grep -v grep | grep first-web-1.0-SNAPSHOT.jar | awk '{print $2}'`
echo 'old Procedure pid: '$pid
if [ -n "$pid" ]
then
kill -9 $pid
fi
# 启动服务
export JAVA_HOME=/usr/java/jdk1.8.0_271-amd64
echo ${JAVA_HOME}
echo 'Start the program : first-web-1.0-SNAPSHOT.jar '
chmod 777 /root/.jenkins/workspace/yang-first/first-web/target/first-web-1.0-SNAPSHOT.jar
echo '-----------------------------------Starting-----------------------------------'
cd /root/.jenkins/workspace/yang-first/first-web/target/
nohup ${JAVA_HOME}/bin/java -jar first-web-1.0-SNAPSHOT.jar >> firt-web-out#`date +%Y-%m-%d#%H-%M-%S`.file 2>&1 &
echo 'start success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
问题:
问题1:fatal: 远端意外挂断了 fatal: 过早的文件结束符(EOF) fatal: index-pack 失败
接收对象中: 55% (636/1145), 5.57 MiB | 9.00 KiB/s
接收对象中: 55% (636/1145), 5.58 MiB | 9.00 KiB/s
接收对象中: 55% (636/1145), 5.59 MiB | 7.00 KiB/s
fatal: 远端意外挂断了
16:01:35 fatal: 过早的文件结束符(EOF)
16:01:35 fatal: index-pack 失败
16:01:35 warning: unable to unlink '(null)': 错误的地址
16:01:35
16:01:35 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
16:01:35 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
16:01:35 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
16:01:35 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
16:01:35 at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:994)
16:01:35 ... 11 more
16:01:35 ERROR: Error fetching remote repo 'origin'
解决方式:
1. 有可能是 网络不稳定的情况
2. 增大 git 缓冲区大小
git config --global http.postBuffer 524288000
问题2:ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [-1]]
20:44:06 Archiving artifacts
20:44:12 SSH: Connecting from host [yang10]
20:44:12 SSH: Connecting with configuration [yang100] ...
20:44:22 SSH: EXEC: completed after 417 ms
20:44:22 SSH: Disconnecting configuration [yang100] ...
20:44:22 ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [-1]]
20:44:22 Build step 'Send build artifacts over SSH' changed build result to UNSTABLE
20:44:24 Finished: UNSTABLE
程序异常的退出了,就是执行 脚本文件的时候,没有正常的结束,但是这个时候,服务应该是起来了
解决方式:
修改 shell 脚本内容 ,添加 grep -v grep
pid=`ps -ef | grep java | grep -v grep | grep first-web-1.0-SNAPSHOT.jar | awk '{print $2}'`
问题3: Exception when publishing, exception message [Exec timed out or was interrupted after 120,004 ms]
20:59:51 Archiving artifacts
20:59:56 SSH: Connecting from host [yang10]
20:59:56 SSH: Connecting with configuration [yang100] ...
21:02:02 SSH: Disconnecting configuration [yang100] ...
21:02:02 ERROR: Exception when publishing, exception message [Exec timed out or was interrupted after 120,004 ms]
21:02:02 Build step 'Send build artifacts over SSH' changed build result to UNSTABLE
21:02:03 Finished: UNSTABLE
执行脚本文件还是没有正常退出,一直等到 连接的超时时间才退出
解决方式:
添加 nohub 指定文件的输出位置
nohup ${JAVA_HOME}/bin/java -jar first-web-1.0-SNAPSHOT.jar >> firt-web-out#`date +%Y-%m-%d#%H-%M-%S`.file 2>&1 &
当出现没有正常结束命令,但是服务已经正常启动的情况,应该将 shell 文件手动的进行执行一下,看看脚本到底是哪里出现了问题