4

我正在尝试设置在所有测试通过后发布lernajenkins我有命令正在运行,但它失败了。

我找不到任何有关如何使其工作的文档。我需要这个命令才能访问将 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, 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

我通过这样做解决了这个问题: Jenkins Git plugin detached HEAD

这是我将所有内容设置为:

在此处输入图像描述

现在我遇到了这个问题:

> 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

我怎样才能lerna publish在詹金斯工作?

4

2 回答 2

0

我进入了詹金斯盒子并cd进入了工作区。

我跑了git remote update,它标准输出了这个:

警告:将 IP 地址“192.30.253.112”的 RSA 主机密钥永久添加到已知主机列表中。

看来我没有添加github的IP。

于 2018-04-24T04:04:16.957 回答
0

您需要确定 Jenkins 使用哪个帐户在 Jenkins 盒子上运行:

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

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

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

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

我已经通过 root SSH 进入机器并且可以查看访问权限。
我正在与用户一起拉下 repo,并使用 Git 插件在 Jenkins 中有一个密钥,但现在 lerna 在该插件之外运行,需要 ssh 访问 repo,它在用户级别不可用。

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

于 2018-04-24T04:40:46.407 回答