Jenkins集成gitee遇到的问题及解决方案

首先贴问题

# 以下带有敏感信息的我都打*了
Started by Gitee push by Gitee
Running as SYSTEM
Building in workspace /root/.jenkins/workspace/text
The recommended git tool is: NONE
using credential ******
 > /usr/local/git/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/local/git/bin/git config remote.origin.url https://gitee.com/*****/ecarport.git # timeout=10
Fetching upstream changes from https://gitee.com/handsome_little_brother_hao/ecarport.git
 > /usr/local/git/bin/git --version # timeout=10
 > git --version # git version 2.23.0
using GIT_ASKPASS to set credentials 
 > /usr/local/git/bin/git fetch --tags --force --progress -- https://gitee.com/handsome_little_brother_hao/ecarport.git +refs/heads/master:refs/remotes/origin/master +refs/pull/*/MERGE:refs/pull/*/MERGE # timeout=10
 > /usr/local/git/bin/git rev-parse remotes/origin/test_version^{
          
   commit} # timeout=10
FATAL: Command "/usr/local/git/bin/git rev-parse remotes/origin/test_version^{commit}" returned status code 128:
stdout: remotes/origin/test_version^{
          
   commit}

stderr: fatal: ambiguous argument remotes/origin/test_version^{commit}: unknown revision or path not in the working tree.
Use -- to separate paths from revisions, like this:
git <command> [<revision>...] -- [<file>...]

hudson.plugins.git.GitException: Command "/usr/local/git/bin/git rev-parse remotes/origin/test_version^{commit}" returned status code 128:
stdout: remotes/origin/test_version^{
          
   commit}

stderr: fatal: ambiguous argument remotes/origin/test_version^{commit}: unknown revision or path not in the working tree.
Use -- to separate paths from revisions, like this:
git <command> [<revision>...] -- [<file>...]

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2380)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2376)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1923)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1935)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:1037)
	at hudson.plugins.git.GitAPI.revParse(GitAPI.java:331)
	at hudson.plugins.git.RevisionParameterAction.toRevision(RevisionParameterAction.java:98)
	at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1137)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1300)
	at hudson.scm.SCM.checkout(SCM.java:505)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
	at hudson.model.Run.execute(Run.java:1907)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

解决方案

1.如果是从gitee webhook 点击测试,只是测试一个连通性问题,webhook带过来的数据不一定能成功构建,

可以试试推送代码或者提交PR来触发,如果你点击测试了gitee没报错但是Jenkins报了以上错误那你可以试试推送代码,我推送代码就🆗了

2.jenkins 的git 源码管理插件新版本有变化,Refspec 不支持多个条目同时使用通配符。

那就可以去这里查看你的写法是否正确 写法可以参考我下面这个 全部用*是不行的

+refs/heads/master:refs/remotes/origin/master
+refs/pull/*/MERGE:refs/pull/*/MERGE

最后可能就是你其他地方没些对 可以去看看

经验分享 程序员 微信小程序 职场和发展