Jenkins特定节点用x-auth-token拉取Bitbucket代码报GitException错误128
摘要
我查阅了“为什么Jenkins拉取Git代码失败但命令行可以?”“Jenkins拉取代码失败”等相关问题及其他搜索结果。
错误信息
某Jenkins节点拉取bitbucket.org仓库失败,但其他多个节点执行完全相同的拉取操作可成功。所有节点均连接至同一Jenkins控制器,x-auth-token存储在控制器的凭证管理器中。
错误命令返回状态码128:
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- https://bitbucket.org/company/reponame.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
补充信息
- 使用相同凭证、以同一Linux用户身份通过命令行执行
git clone可成功。 - 在安装相同Jenkins插件版本的其他Linux主机上,相同任务可成功执行。
- 错误出现在脚本化Jenkinsfile中。
- 我创建了一个仅执行拉取操作的简单自由风格任务,同样出现该错误,以下日志来自此任务。
我在环境变量中添加了GIT_TRACE=1以获取更多日志信息。
节点company-dev02上的成功日志
由用户 User name 启动 以SYSTEM身份运行 [EnvInject] - 加载节点环境变量。 [EnvInject] - 准备构建环境。 [EnvInject] - 保留Jenkins系统变量。 [EnvInject] - 保留Jenkins构建变量。 [EnvInject] - 将属性内容作为环境变量注入 GIT_TRACE=1 [EnvInject] - 变量注入成功。 [EnvInject] - 注入贡献内容。 在远程节点company-dev02(标签:developmenthost linuxreleasehost linux latest22_linux_db test22cloud_linux_db test22_linux_db develop23_linux_db develop_linux_db)的工作区/var/lib/jenkins/workspace/cceadm appltest22/xcomp checkout company-dev02中构建 [EnvInject] - 清除未解析的'BASH_FUNC_which%%'变量。 推荐的Git工具为:NONE 使用凭证tokentokenTOKENTOKEN 克隆远程Git仓库 克隆仓库https://bitbucket.org/company/reponame.git > git init /var/lib/jenkins/workspace/cceadm appltest22/xcomp checkout company-dev02 # 超时时间=10 从https://bitbucket.org/company/reponame.git获取上游变更 > git --version # 超时时间=10 > git --version # 'git version 2.31.1' 使用GIT_ASKPASS设置凭证token TOKENTOKEN > git fetch --tags --force --progress -- https://bitbucket.org/company/reponame.git +refs/heads/*:refs/remotes/origin/* # 超时时间=10 > git config remote.origin.url https://bitbucket.org/company/reponame.git # 超时时间=10 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # 超时时间=10 避免二次拉取 > git rev-parse refs/remotes/origin/xcomp/22.0/test^{commit} # 超时时间=10 > git rev-parse xcomp/22.0/test^{commit} # 超时时间=10 检出版本e7ce93ef07cdaff3ae372dfed57c93ccf3ebbd84(refs/remotes/origin/xcomp/22.0/test) > git config core.sparsecheckout # 超时时间=10 > git checkout -f e7ce93ef07cdaff3ae372dfed57c93ccf3ebbd84 # 超时时间=10 提交信息:"Merge branch 'user/config/company-812-Cloud-build' into xcomp/22.0/test" > git rev-list --no-walk e7ce93ef07cdaff3ae372dfed57c93ccf3ebbd84 # 超时时间=10 18:51:17.933383 git.c:447 trace: built-in: git whatchanged --no-abbrev -M '--format=commit %H%ntree %T%nparent %P%nauthor %aN <%aE> %ai%ncommitter %cN <%cE> %ci%n%n%w(0,4,4)%B' -n 1024 e7ce93ef07cdaff3ae372dfed57c93ccf3ebbd84 ^e7ce93ef07cdaff3ae372dfed57c93ccf3ebbd84 推荐的Git工具为:NONE 使用凭证tokentokenTOKENTOKEN > git rev-parse e7ce93ef07cdaff3ae372dfed57c93ccf3ebbd84^{commit} # 超时时间=10 推荐的Git工具为:NONE 使用凭证tokentokenTOKENTOKEN [GitCheckoutListener] 记录'git https://bitbucket.org/company/reponame.git'的提交 [GitCheckoutListener] 找到包含已记录Git提交的上一次构建'cceadm appltest22/xcomp checkout company-dev02 #2' [GitCheckoutListener] -> 开始记录从'e7ce93e'之后的新提交 [GitCheckoutListener] -> 发现多个父提交 - 存储本地合并'e7ce93e'的最新提交 [GitCheckoutListener] -> 使用本地合并的父提交'05cef30'作为起始点 [GitCheckoutListener] -> 存储目标分支头'74f329b'(本地合并的第二个父提交) [GitCheckoutListener] -> 记录了200个新提交 [GitCheckoutListener] -> 最新提交'e7ce93ef07cdaff3ae372dfed57c93ccf3ebbd84'是合并提交 [GitCheckoutListener] -> Git提交装饰器成功获取'hudson.plugins.git.browser.BitbucketWeb@72f603c0'以渲染提交链接 构建完成:SUCCESS
失败日志
由用户 User name 启动 以SYSTEM身份运行 [EnvInject] - 加载节点环境变量。 [EnvInject] - 准备构建环境。 [EnvInject] - 保留Jenkins系统变量。 [EnvInject] - 保留Jenkins构建变量。 [EnvInject] - 将属性内容作为环境变量注入 GIT_TRACE=1 [EnvInject] - 变量注入成功。 [EnvInject] - 注入贡献内容。 在远程节点company-admdb(标签:applprod22_linux_db linux appltest22_linux_db)的工作区/var/lib/jenkins/workspace/cceadm appltest22/xcomp checkout中构建 [EnvInject] - 清除未解析的'BASH_FUNC_which%%'变量。 推荐的Git工具为:NONE 使用凭证tokentokenTOKENTOKEN 克隆远程Git仓库 克隆仓库https://bitbucket.org/company/reponame.git > git init /var/lib/jenkins/workspace/cceadm appltest22/xcomp checkout # 超时时间=10 从https://bitbucket.org/company/reponame.git获取上游变更 > git --version # 超时时间=10 > git --version # 'git version 2.31.1' 使用GIT_ASKPASS设置凭证token TOKENTOKEN > git fetch --tags --force --progress -- https://bitbucket.org/company/reponame.git +refs/heads/*:refs/remotes/origin/* # 超时时间=10 错误:克隆远程仓库'origin'失败 hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- https://bitbucket.org/company/reponame.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: 标准输出: 标准错误:18:54:05.328181 git.c:447 trace: built-in: git fetch --tags --force --progress -- https://bitbucket.org/company/reponame.git '+refs/heads/*:refs/remotes/origin/*' 18:54:05.328405 run-command.c:667 trace: run_command: GIT_DIR=.git git remote-https https://bitbucket.org/company/reponame.git https://x-token-auth:*******************************************************************************************@bitbucket.org/company/reponame.git 18:54:05.330301 git.c:733 trace: exec: git-remote-https https://bitbucket.org/company/reponame.git https://x-token-auth:*******************************************************************************************@bitbucket.org/company/reponame.git 18:54:05.330335 run-command.c:667 trace: run_command: git-remote-https https://bitbucket.org/company/reponame.git https://x-token-auth:*******************************************************************************************@bitbucket.org/company/reponame.git remote: 请求的仓库不存在或您无访问权限。如果您认为仓库存在且您有访问权限,请确认已完成身份验证。 fatal: 无法访问'https://bitbucket.org/company/reponame.git/': 请求的URL返回错误: 403 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2842) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:871) at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:170) at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161) at hudson.remoting.UserRequest.perform(UserRequest.java:211) at hudson.remoting.UserRequest.perform(UserRequest.java:54) at hudson.remoting.Request$2.run(Request.java:377) at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Suppressed: hudson.remoting.Channel$CallSiteStackTrace: 远程调用至company-admdb at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787) at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356) at hudson.remoting.Channel.call(Channel.java:1003) at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:153) at jdk.internal.reflect.GeneratedMethodAccessor2090.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:138) at jdk.proxy123/jdk.proxy123.$Proxy256.execute(Unknown Source) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1222) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305) at hudson.scm.SCM.checkout(SCM.java:540) at hudson.model.AbstractProject.checkout(AbstractProject.java:1248) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:521) at hudson.model.Run.execute(Run.java:1895) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:442) 错误:克隆远程仓库'origin'失败 构建完成:FAILURE
内容的提问来源于stack exchange,提问作者carl verbiest
相关产品推荐
相关产品推荐

