报错信息1:Exception when publishing, exception message

最近一直在做Jenkins项目,也经常会出现一些报错信息,今天在测试的时候出现了下面的报错信息,所以现在记录一下我的报错过程及解决方案。

...............省略部分内容........................

[JENKINS] Archiving /root/.jenkins/workspace/one_plus/target/easy-springmvc-maven.war to springmvc-maven/easy-springmvc-maven/0.0.1-SNAPSHOT/easy-springmvc-maven-0.0.1-SNAPSHOT.war

channel stopped

SSH: Connecting from host [bogon]

SSH: Connecting with configuration [test] ...

ERROR: Exception when publishing, exception message [Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [test]. Message [java.net.NoRouteToHostException: 没有到主机的路由 (Host unreachable)]]]

Finished: UNSTABLE

原因及解决办法: 在我思考并查找后发现原因是我的连接的后端服务器IP地址改变了,我之前用的地址是192.168.119.134,但是因为后端地址改变了没有更换所以连接不成功。

解决:更换为正确的地址测试成功,再次发送Jenkins服务器端的密钥

[root@bogon ~]# ssh-copy-id -i root@192.168.119.148

重新构建:成功

报错信息2:

Started by user jun

Running as SYSTEM

Building in workspace /root/.jenkins/workspace/test

The recommended git tool is: NONE

No credentials specified

Cloning the remote Git repository

Cloning repository https://gitee.com/yangge666a/testweb

> git init /root/.jenkins/workspace/test # timeout=10

ERROR: Error cloning remote repo 'origin'

hudson.plugins.git.GitException: Could not init /root/.jenkins/workspace/test

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:1049)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:802)

at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1225)

at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1308)

at hudson.scm.SCM.checkout(SCM.java:540)

at hudson.model.AbstractProject.checkout(AbstractProject.java:1217)

at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:647)

at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)

at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:519)

at hudson.model.Run.execute(Run.java:1897)

at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)

at hudson.model.ResourceController.execute(ResourceController.java:101)

at hudson.model.Executor.run(Executor.java:442)

Caused by: hudson.plugins.git.GitException: Error performing git command: git init /root/.jenkins/workspace/test

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2746)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2660)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2656)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1981)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:1047)

... 12 more

Caused by: java.io.IOException: Cannot run program "git" (in directory "/root/.jenkins/workspace/test"): error=2, 没有那个文件或目录

at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)

at hudson.Proc$LocalProc.(Proc.java:254)

at hudson.Proc$LocalProc.(Proc.java:223)

at hudson.Launcher$LocalLauncher.launch(Launcher.java:997)

at hudson.Launcher$ProcStarter.start(Launcher.java:509)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2727)

... 16 more

Caused by: java.io.IOException: error=2, 没有那个文件或目录

at java.lang.UNIXProcess.forkAndExec(Native Method)

at java.lang.UNIXProcess.(UNIXProcess.java:247)

at java.lang.ProcessImpl.start(ProcessImpl.java:134)

at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

... 21 more

ERROR: Error cloning remote repo 'origin'

Sending e-mails to: yolo_yi@163.com

Finished: FAILURE

解决方案:

java.io.IOException: Cannot run program “git” (in directory “/root/.jenkins/workspace/test”): error=2, 没有那个文件或目录,看了这句话说不能运行git项目,说明在jenkins服务器上没有安装git

在Jenkins服务器上做了以下操作

[root@localhost ]# yum -y install git

报错信息3:ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [127]]

...................前面信息太多省略........................

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 01:39 min

[INFO] Finished at: 2023-01-15T21:07:55+08:00

[INFO] ------------------------------------------------------------------------

Waiting for Jenkins to finish collecting data

[JENKINS] Archiving /root/.jenkins/workspace/test/pom.xml to springmvc-maven/easy-springmvc-maven/0.0.1-SNAPSHOT/easy-springmvc-maven-0.0.1-SNAPSHOT.pom

[JENKINS] Archiving /root/.jenkins/workspace/test/target/easy-springmvc-maven.war to springmvc-maven/easy-springmvc-maven/0.0.1-SNAPSHOT/easy-springmvc-maven-0.0.1-SNAPSHOT.war

SSH: Connecting from host [localhost]

SSH: Connecting with configuration [test162] ...

channel stopped

SSH: EXEC: completed after 214 ms

SSH: Disconnecting configuration [test162] ...

ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [127]]

Sending e-mails to: yolo_yi@163.com

Finished: UNSTABLE

原因:没有将脚本文件放在脚本目录下

我定义的: 但是我存放的错误: 再次构建成功:

报错信息4:

Started by user jun

Running as SYSTEM

Building in workspace /root/.jenkins/workspace/gitlab

The recommended git tool is: NONE

using credential 43d744f4-170f-426d-a34b-cccca19404b9

> git rev-parse --resolve-git-dir /root/.jenkins/workspace/gitlab/.git # timeout=10

Fetching changes from the remote Git repository

> git config remote.origin.url git@192.168.119.161:root/jenkins-for-gitlab.git # timeout=10

Fetching upstream changes from git@192.168.119.161:root/jenkins-for-gitlab.git

> git --version # timeout=10

> git --version # 'git version 1.8.3.1'

using GIT_SSH to set credentials gitlab

Verifying host key using known hosts file

> git fetch --tags --progress git@192.168.119.161:root/jenkins-for-gitlab.git +refs/heads/*:refs/remotes/origin/* # timeout=10

ERROR: Error fetching remote repo 'origin'

hudson.plugins.git.GitException: Failed to fetch from git@192.168.119.161:root/jenkins-for-gitlab.git

at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1002)

at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1244)

at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1308)

at hudson.scm.SCM.checkout(SCM.java:540)

at hudson.model.AbstractProject.checkout(AbstractProject.java:1217)

at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:647)

at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)

at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:519)

at hudson.model.Run.execute(Run.java:1897)

at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)

at hudson.model.ResourceController.execute(ResourceController.java:101)

at hudson.model.Executor.run(Executor.java:442)

Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@192.168.119.161:root/jenkins-for-gitlab.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:

stdout:

stderr: No ECDSA host key is known for 192.168.119.161 and you have requested strict checking.

Host key verification failed.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2734)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2111)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:87)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:623)

at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1000)

... 11 more

ERROR: Error fetching remote repo 'origin'

Finished: FAILURE

出错原因:

stderr: No ECDSA host key is known for 192.168.119.161 and you have requested strict checking. Host key verification failed. fatal: Could not read from remote repository.

通过这几行可以看出192.168.119.161没有被分发密钥,所以主机认证失败

解决:

##我们在Jenkins向gitlab分发密钥,再次构建

[root@localhost ~]# ssh-copy-id -i root@192.168.119.161

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"

The authenticity of host '192.168.119.161 (192.168.119.161)' can't be established.

ECDSA key fingerprint is SHA256:ntUPfvW1LRY8s42ot/wG2AlcFvtzgig3SJWTGLCnTLI.

ECDSA key fingerprint is MD5:5a:a0:c9:8a:24:63:fb:90:82:1f:d8:aa:4d:5d:67:2f.

Are you sure you want to continue connecting (yes/no)? yes

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@192.168.119.161's password:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'root@192.168.119.161'"

and check to make sure that only the key(s) you wanted were added.

[root@localhost ~]# ssh root@192.168.119.161

Last login: Sun Jan 15 21:26:00 2023 from 192.168.119.1

[root@localhost ~]# exit

登出

Connection to 192.168.119.161 closed.

参考链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: