【问题标题】:Git command not working in jenkins pipeline - but when i run it locally it worksGit命令在jenkins管道中不起作用-但是当我在本地运行它时它可以工作
【发布时间】:2017-11-21 23:28:25
【问题描述】:

我在 jenkins 中运行的脚本有时包含以下命令:

npm update fhir-types --force

结果是:

C:\Sources\iw-next\iw.next-ui>npm update fhir-types --force npm WARN 使用 --force 我当然希望你知道你在做什么。 npm 错误!代码 128 npm 错误!命令失败:C:\Program Files\Git\cmd\git.EXE 克隆 --depth=1 -q -b dev https://bitbucket.org/asd/fhir-types.git C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache_cacache\tmp\git-clone-1b2dca91 --config core.longpaths=true npm 错误!警告:找不到模板 C:\Windows\TEMP\pacote-git-template-tmp\git-clone-fd08367f npm ERR! 远程:无效的用户名或密码。如果您通过第三方登录 服务,您必须确保在您的帐户中设置了帐户密码 帐户资料。 npm 错误!致命:身份验证失败 'https://bitbucket.org/asd/fhir-types.git/' npm 错误!

npm 错误!可以在以下位置找到此运行的完整日志:npm ERR!
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm-cache_logs\2017-11-21T07_55_14_306Z-debug.log

当我在本地运行它时,它可以工作 - 在我运行此更新之前,是否可以在命令行中为 git 更改用户和密码?

【问题讨论】:

  • fatal: Authentication failed,在 Jenkins 作业中运行 npm update 的用户似乎无权访问远程存储库。
  • 在 jenkins 中配置的用于连接到该从节点的用户与我使用 RDC 手动连接时使用的用户相同 - 当我手动连接时它可以工作 - 当我从 jenkins 运行时它不会 - 你知道我可以在 npm 更新之前使用命令行手动配置用户的方法吗?

标签: git jenkins


【解决方案1】:

这可能是一些事情。有时 Jenkins 无法运行npm update/install,因为文件系统没有正确的权限。要解决此问题,请在文件系统上运行此命令。

chmod -R 777 /path/to/jenkins

根据经验,我发现 Jenkins 上的 npm 出现问题有时是由于 Git 配置不当造成的。也可以尝试一些 npm 配置设置。我建议从 Jenkins 作业中的自定义 shell 运行其余命令。

对于初学者,请确保您的 Git 用户名和电子邮件已设置。然后禁用 SSL。禁用此功能并不是最安全的,有些人认为它是一种黑客攻击,但它在很多情况下都有效。

git config --global user.name "BobDole"
git config --global user.name "bob.dole@cheescakefactory.org"
git config --global http.sslVerify false

您似乎正在使用私有 Bitbucket 存储库来保存您的 npm 包。未发布到公共 npm 存储库的 NPM 包对 Jenkins 有点挑剔。您可能需要自己尝试一些 npm 配置设置,看看有什么效果:https://docs.npmjs.com/misc/config

我的第一个建议是尝试将注册表明确设置为公共 npm 注册表。过去,这对我和 Jenkins 都有效。

npm config set registry https://registry.npmjs.org/

【讨论】:

  • 您好,我们会尝试以上建议并回复您 - 谢谢!
  • 确实使用了全局用户名:git config --global user.name "BobDole" git config --global user.name "bob.dole@cheescakefactory.org" git config --global http。 sslVerify false 似乎在使用这些后工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-23
  • 2012-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-19
  • 2019-10-12
相关资源
最近更新 更多