lerna在Jenkins上发布“git remote update”失败“无法从远程存储库读取”。 [英] lerna publish on Jenkins "git remote update" Fails "Could not read from remote repository."

查看:1595
本文介绍了lerna在Jenkins上发布“git remote update”失败“无法从远程存储库读取”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的所有测试通过之后用 jenkins 设置 lerna 来发布。我有命令运行但失败。

我找不到任何关于如何使其工作的文档。我需要这个命令才能访问lerna标签,以及更新后的版本号到master分支,我还需要Jenkins不会陷入无限循环。



我的第一个问题是这样的:

 > lerna publish --yes --cd-version = patch 

lerna info version 3.0.0-beta.17
lerna info versioning independent
lerna ERR! ENOGIT Detached git HEAD,请检查分支以发布更改。
npm ERR!代码ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0发布:`lerna publish --yes --cd-version = patch`
npm ERR!退出状态1
npm ERR!
npm ERR!在abide@1.0.0发布脚本失败。
npm ERR!这可能不是npm的问题。上面可能还有其他日志记录输出。

npm ERR!此运行的完整日志可在以下位置找到:
npm ERR! /var/lib/jenkins/.npm/_logs/2018-04-24T03_18_59_152Z-debug.log
npm ERR!代码ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0 jenkins:`npm run versions&& npm运行测试&& npm run publish`
npm ERR!退出状态1
npm ERR!
npm ERR!在abide@1.0.0 jenkins脚本失败。
npm ERR!这可能不是npm的问题。上面可能还有其他日志记录输出。

npm ERR!此运行的完整日志可在以下位置找到:
npm ERR! /var/lib/jenkins/.npm/_logs/2018-04-24T03_18_59_167Z-debug.log
构建步骤'Execute shell'标记构建失败
完成:FAILURE

我通过这样做来修复:



现在我遇到这个问题:

 > lerna publish --yes --cd-version = patch 

lerna info version 3.0.0-beta.17
lerna info versioning independent
lerna ERR!错误:命令失败:git远程更新
lerna ERR!权限被拒绝(publickey)。
lerna ERR!致命:无法从远程存储库读取。
lerna ERR!
lerna ERR!请确保您拥有正确的访问权限
lerna ERR!并存在该存储库。
lerna ERR!错误:无法获取原点
lerna ERR!
lerna ERR!正在获取原点
lerna ERR!
lerna ERR!在makeError(/var/lib/jenkins/workspace/abide/node_modules/@lerna/child-process/node_modules/execa/index.js:169:9)
lerna ERR!在Function.module.exports.sync(/var/lib/jenkins/workspace/abide/node_modules/@lerna/child-process/node_modules/execa/index.js:338:15)
lerna ERR!在Object.execSync(/var/lib/jenkins/workspace/abide/node_modules/@lerna/child-process/index.js:21:16)
lerna ERR!在Object.isBehindUpstream(/var/lib/jenkins/workspace/abide/node_modules/@lerna/git-utils/index.js:206:25)
lerna ERR!在PublishCommand.initialize(/var/lib/jenkins/workspace/abide/node_modules/@lerna/publish/index.js:92:24)
lerna ERR!在Promise.resolve.then(/var/lib/jenkins/workspace/abide/node_modules/@lerna/command/index.js:228:24)
lerna ERR! lerna命令失败:git远程更新
lerna ERR! lerna权限被拒绝(publickey)。
lerna ERR! lerna致命:无法从远程存储库读取。
lerna ERR! lerna
lerna ERR! lerna请确保您拥有正确的访问权限
lerna ERR! lerna和存储库存在。
lerna ERR! lerna错误:无法获取原点
lerna ERR! lerna
lerna ERR! lerna抓取原点
lerna ERR! lerna
npm ERR!代码ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0发布:`lerna publish --yes --cd-version = patch`
npm ERR!退出状态1
npm ERR!
npm ERR!在abide@1.0.0发布脚本失败。
npm ERR!这可能不是npm的问题。上面可能还有其他日志记录输出。

npm ERR!此运行的完整日志可在以下位置找到:
npm ERR! /var/lib/jenkins/.npm/_logs/2018-04-24T03_29_06_133Z-debug.log
npm ERR!代码ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0 jenkins:`npm run versions&& npm运行测试&& npm run publish`
npm ERR!退出状态1
npm ERR!
npm ERR!在abide@1.0.0 jenkins脚本失败。
npm ERR!这可能不是npm的问题。上面可能还有其他日志记录输出。

npm ERR!此运行的完整日志可在以下位置找到:
npm ERR! /var/lib/jenkins/.npm/_logs/2018-04-24T03_29_06_144Z-debug.log
构建步骤'Execute shell'标记构建失败
完成:FAILURE

如何获得 lerna publish 在Jenkins中工作?

解决方案

您需要确定詹金斯在Jenkins盒子上运行的是哪个帐户:

如果您有正确的〜/ .ssh / id_rsa(.pub)私钥/公钥,则Jenkins必须与该用户一起运行〜以反映正确的HOME。 / p>

如果您可以连接到Jenkins机器,则可以使用以下方法测试您的ssh连接:

  cd / apth / to / repo 
git remote -v
#应该返回一个ssh URL
#like:
#git@aserver.com
ssh -T git@aserver.com

OP ThomasReggi 确认帐户问题在评论中:


我已经通过root用SSH进入机器并可以查看访问权限。

我正在将用户的回购协议拉下来, Jenkins使用Git插件的一个关键,但现在lerna在该插件之外运行,需要ssh访问repo,并且在用户级别不可用。



所有我需要做的是添加SSH代理插件,并在我的作业配置中使用我用来设置GitHub插件的相同SSH凭证。



I am trying to set up lerna with jenkins to publish after all my tests pass. I have the command running but it's failing.

I can't find any documentation on how to get this to work. I need this command to have access to push the lerna tags, as well as the updated version numbers to the master branch, and I also need Jenkins to not fall into an infinite loop.

My first issue was this:

> lerna publish --yes --cd-version=patch

lerna info version 3.0.0-beta.17
lerna info versioning independent
lerna ERR! ENOGIT Detached git HEAD, please checkout a branch to publish changes.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0 publish: `lerna publish --yes --cd-version=patch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the abide@1.0.0 publish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/lib/jenkins/.npm/_logs/2018-04-24T03_18_59_152Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0 jenkins: `npm run versions && npm run test && npm run publish`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the abide@1.0.0 jenkins script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/lib/jenkins/.npm/_logs/2018-04-24T03_18_59_167Z-debug.log
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Which I fixed by doing this: Jenkins Git plugin detached HEAD

Here's what I set everything to:

Now I am having this issue:

> lerna publish --yes --cd-version=patch

lerna info version 3.0.0-beta.17
lerna info versioning independent
lerna ERR! Error: Command failed: git remote update
lerna ERR! Permission denied (publickey).
lerna ERR! fatal: Could not read from remote repository.
lerna ERR! 
lerna ERR! Please make sure you have the correct access rights
lerna ERR! and the repository exists.
lerna ERR! error: Could not fetch origin
lerna ERR! 
lerna ERR! Fetching origin
lerna ERR! 
lerna ERR!     at makeError (/var/lib/jenkins/workspace/abide/node_modules/@lerna/child-process/node_modules/execa/index.js:169:9)
lerna ERR!     at Function.module.exports.sync (/var/lib/jenkins/workspace/abide/node_modules/@lerna/child-process/node_modules/execa/index.js:338:15)
lerna ERR!     at Object.execSync (/var/lib/jenkins/workspace/abide/node_modules/@lerna/child-process/index.js:21:16)
lerna ERR!     at Object.isBehindUpstream (/var/lib/jenkins/workspace/abide/node_modules/@lerna/git-utils/index.js:206:25)
lerna ERR!     at PublishCommand.initialize (/var/lib/jenkins/workspace/abide/node_modules/@lerna/publish/index.js:92:24)
lerna ERR!     at Promise.resolve.then (/var/lib/jenkins/workspace/abide/node_modules/@lerna/command/index.js:228:24)
lerna ERR! lerna Command failed: git remote update
lerna ERR! lerna Permission denied (publickey).
lerna ERR! lerna fatal: Could not read from remote repository.
lerna ERR! lerna 
lerna ERR! lerna Please make sure you have the correct access rights
lerna ERR! lerna and the repository exists.
lerna ERR! lerna error: Could not fetch origin
lerna ERR! lerna 
lerna ERR! lerna Fetching origin
lerna ERR! lerna 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0 publish: `lerna publish --yes --cd-version=patch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the abide@1.0.0 publish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/lib/jenkins/.npm/_logs/2018-04-24T03_29_06_133Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0 jenkins: `npm run versions && npm run test && npm run publish`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the abide@1.0.0 jenkins script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/lib/jenkins/.npm/_logs/2018-04-24T03_29_06_144Z-debug.log
Build step 'Execute shell' marked build as failure
Finished: FAILURE

How can I get lerna publish to work in Jenkins?

解决方案

You need to make sure with which account Jenkins is running on the Jenkins box:

If you do have the right ~/.ssh/id_rsa(.pub) private/public key, Jenkins must run with that user for ~ to reflect the right HOME.

If you can connect to the Jenkins machine, you can then test your ssh connection with:

cd /apth/to/repo
git remote -v
  # should return an ssh URL
  # like:
  # git@aserver.com
ssh -T git@aserver.com

The OP ThomasReggi confirms the account issue in the comments with:

I have been SSH'd into the machine via root and can view access.
I am pulling the repo down with a user and have a key in Jenkins using the Git plugin, but now lerna is running outside that plugin and needs ssh access to the repo and it's not available at the user level.

All I needed to do was add the SSH Agent plugin and in my job's configure use the same SSH credentials I used to setup the GitHub plugin.

这篇关于lerna在Jenkins上发布“git remote update”失败“无法从远程存储库读取”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆