在从Jenkins执行`pod install & update`时出现错误。

huangapple go评论59阅读模式
英文:

While pod install & update from Jenkins getting Error

问题

以下是代码部分的翻译:

[iOSTestBuild] $ /bin/sh -xe /var/folders/7h/c_dd36k5627bbs6pbhd4zglw0000gn/T/jenkins10828028391649479003.sh
+ /opt/homebrew/bin/pod install --repo update
    [33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
    Consider adding the following to ~/.profile:

    export LANG=en_US.UTF-8
    [0m
/opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/executable.rb:118:in `block in which!': [31m[!] Unable to locate the executable `git`[0m (Pod::Informative)
	from <internal:kernel>:90:in `tap'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/executable.rb:117:in `which!'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/executable.rb:143:in `capture_command'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/command.rb:126:in `git_version'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/command.rb:140:in `verify_minimum_git_version!'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/command.rb:49:in `run'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/bin/pod:55:in `<top (required)>'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/bin/pod:25:in `load'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/bin/pod:25:in `<main>'
Build step 'Execute shell' marked build as failure
Finished: FAILURE

希望这对您有所帮助。

英文:
[iOSTestBuild] $ /bin/sh -xe /var/folders/7h/c_dd36k5627bbs6pbhd4zglw0000gn/T/jenkins10828028391649479003.sh
+ /opt/homebrew/bin/pod install --repo update
    [33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
    Consider adding the following to ~/.profile:

    export LANG=en_US.UTF-8
    [0m
/opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/executable.rb:118:in `block in which!': [31m[!] Unable to locate the executable `git`[0m (Pod::Informative)
	from <internal:kernel>:90:in `tap'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/executable.rb:117:in `which!'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/executable.rb:143:in `capture_command'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/command.rb:126:in `git_version'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/command.rb:140:in `verify_minimum_git_version!'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/lib/cocoapods/command.rb:49:in `run'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/gems/cocoapods-1.12.0/bin/pod:55:in `<top (required)>'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/bin/pod:25:in `load'
	from /opt/homebrew/Cellar/cocoapods/1.12.0/libexec/bin/pod:25:in `<main>'
Build step 'Execute shell' marked build as failure
Finished: FAILURE

On my Mac, when I run the same command it works, only through Jenkins when I run the command it gives me this error.

答案1

得分: 1

  1. 检查运行 Jenkins 的机器上是否存在 Git 可执行文件,可以使用以下命令来检查:git --version
  2. 如果已安装 Git,请确保可执行文件位于系统路径中,可以运行 echo $PATH 来检查,如果不在其中,请设置。
  3. 在 Jenkins 外部尝试运行 pod install 命令,如果成功运行,请尝试在 Jenkins 构建脚本中指定 Git 可执行文件的完整路径。
    或者,您可以直接将 Git 可执行文件的路径添加到 Jenkins 配置中的 PATH 环境变量中。
英文:

Looks like the machine on which you are running jenkins is unable to locate git executable, you can try following commands to troubleshoot it:

  1. Check if git is there on the machine running jenkins using: git --version
  2. If git is installed, ensure the executable is in the system path by running echo $PATH, if its not there set it.
  3. Try pod install command outside of Jenkins and if it works then try specifying the full path to the git executable in the Jenkins build script.
    Alternatively, you can add the path to the git executable directly to the PATH environment variable in the Jenkins configuration

答案2

得分: 0

如果它在Shell中运行正常,但在Jenkins上不行,那说明环境/用户不同。

在Jenkins上,添加到你的任务命令以查看你的用户和环境,以及它在哪里找到 git

id -a
env
which git

这样,你将看到需要添加到用户环境的内容,以便将Git添加到你的 $PATH 中,就像你的Jenkins代理(假设它在你的Mac上运行)能够做到的那样。

英文:

If it work through shell, but not on Jenkins, that means the environment/user is different.

On Jenkins, add to your job commands to see what your user and environment are, as well as where it finds git.

id -a
env
which git

That way, you will see what you need to add to your user environment in order to get Git in your $PATH, like your Jenkins agent (assuming it is running on your Mac) is able to do.

huangapple
  • 本文由 发表于 2023年4月17日 20:36:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76035227.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定