相关推荐recommended
jenkins构建git项目timeout
作者:mmseoamin日期:2024-02-05

问题点:

Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/test-one
using credential f28d956-8ee1-4f20-a32b-06879b487c70
Cloning the remote Git repository
Cloning repository http://git.cc.com/zeg/os.git
 > /usr/bin/git init /var/jenkins_home/workspace/test-one # timeout=10
Fetching upstream changes from http://git.cc.com/zeg/os.git
 > /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials 构建专用账户
 > /usr/bin/git fetch --tags --force --progress -- http://git.cc.com/zeg/os.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > /usr/bin/git config remote.origin.url http://git.cc.com/zeg/os.git# timeout=10
 > /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > /usr/bin/git config remote.origin.url http://git.cc.com/zeg/os.git # timeout=10
Fetching upstream changes from http://git.cc.com/zeg/os.git
using GIT_ASKPASS to set credentials 构建专用账户
 > /usr/bin/git fetch --tags --force --progress -- http://git.cc.com/zeg/os.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > /usr/bin/git rev-parse origin/$branch^{commit} # timeout=10
 > /usr/bin/git rev-parse $branch^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE

查看问题:

找到路径下单条指令执行上述命令

#[root@git ~]# docker exec -it dfdf756561587 /bin/bash 登录容器查看

#git init /var/jenkins_home/workspace/test-one项目目录下面查看是否存在.git文件

#git fetch --tags --force --progress – http://git.cc.com/zeg/os.git +refs/heads/:refs/remotes/origin/

#git config remote.origin.url http://git.cc.com/zeg/os.git

#git config --add remote.origin.fetch +refs/heads/:refs/remotes/origin/

#git config remote.origin.url http://git.cc.com/zeg/os.git

#git fetch --tags --force --progress – http://git.cc.com/zeg/os.git +refs/heads/:refs/remotes/origin/

执行完成后,再到jenkins看看构建。

发现再次编译报错不同了:

Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/test-one
using credential f28d93434-8ee1-4f20-a32b-0c9043487c70
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url http://git.cc.com/zeg/os.git # timeout=10
Fetching upstream changes from http://git.cc.com/zeg/os.git
 > /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials 构建专用账户
 > /usr/bin/git fetch --tags --force --progress -- http://git.cc.com/zeg/os.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > /usr/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 5478970517c45925c383890b6a7b2066f8db003 (refs/remotes/origin/master)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f 5478970517c486925c383890b6a7b2066f8db003 # timeout=10
Commit message: "Merge remote-tracking branch 'origin/test'"
First time build. Skipping changelog.
[test-one] $ /bin/sh -xe /tmp/jenkins3276891310935118132.sh
+ java -jar /home/jenkins/jk_home/deployHistory/aliImg.jar hui off next
+ export 'moduleVer=1.0.1291'
+ echo '新版本=1.0.1291'
新版本=1.0.1291
+ echo 1.0.1291
+ sed -i 's/artifactId>.*.*<\/version>/artifactId>1.0.1291<\/version>/' api-impl/api-impl-off/pom.xml
+ cd common
+ mvn install
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
Build step 'Execute shell' marked build as failure
[test-one] $ /bin/sh -xe /tmp/jenkins7001931897332979233.sh
+ git rev-parse HEAD
+ export 'rev=5478970517c486925c383890b6a7b2066f8db003'
+ echo 5478970517c486925c383890b6a7b2066f8db003
+ cat api-impl/api-impl-off/ver.txt
+ export 'moduleVer=1.0.1291'
+ rm -f ver-off-1.0.1291-5478970517c486925c383890b6a7b2066f8db003
+ echo off-1.0.1291-5478970517c486925c383890b6a7b2066f8db003
SSH: Current build result is [FAILURE], not going to run.
[test-one] $ /usr/local/maven-3.5.4/bin/mvn -s /usr/local/maven-3.5.4/conf/settings.xml -gs /usr/local/maven-3.5.4/conf/settings.xml
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

到环境目录下直接执行:

#/usr/local/maven-3.5.4/bin/mvn -s /usr/local/maven-3.5.4/conf/settings.xml -gs /usr/local/maven-3.5.4/conf/settings.xml

jenkins构建git项目timeout,在这里插入图片描述,第1张

此错误是项目没有指定执行目标。


compile

加入后再linux执行

bash-4.4# /usr/local/maven-3.5.4/bin/mvn -s /usr/local/maven-3.5.4/conf/settings.xml -gs /usr/local/maven-3.5.4/conf/settings.xml

编译完成。

那么jenkins为什么会报错误呢?

[test-one] $ /usr/local/maven-3.5.4/bin/mvn -s /usr/local/maven-3.5.4/conf/settings.xml -gs /usr/local/maven-3.5.4/conf/settings.xml
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE