Jenkins Build for Yarn Bin Lerna命令失败
我正在尝试使用jenkins的管道中的YARN bin leerna
命令,但由于尝试以SSH凭据获取/更新git git存储库而失败。
在多支酒店项目中使用以下Jenkinsfile。
stages {
stage('Install NPM Deps') {
steps {
configFileProvider([configFile(
fileId: 'npm-auth',
targetLocation: '.npmrc'
)]) {
withCredentials([sshUserPrivateKey(credentialsId: 'cred-id', keyFileVariable: 'KEY')]) {
withEnv(['GIT_SSH=ssh -i ${KEY} -l git']) {
script {
docker.image("node").inside("-u0 -vnode_home:/.npm") {
sh 'yarn'
sh 'yarn clean --yes'
sh 'yarn bootstrap'
sh '$(yarn bin lerna) version ${VERSION}'
//sh 'yarn test'
//sh 'yarn deploy'
}
}
}
}
}
}
运行管道时错误。
+ yarn bin lerna
+ /var/jenkins/workspace/test-lib/node_modules/.bin/lerna version patch
lerna notice cli v3.22.1
lerna info versioning independent
lerna info ci enabled
lerna ERR! Error: Command failed: git remote update
lerna ERR! error: cannot run ssh -l git: No such file or directory
lerna ERR! fatal: unable to fork
lerna ERR! error: Could not fetch origin
lerna ERR!
lerna ERR! Fetching origin
lerna ERR! lerna Command failed: git remote update
lerna ERR! lerna error: cannot run ssh -l git: No such file or directory
lerna ERR! lerna fatal: unable to fork
lerna ERR! lerna error: Could not fetch origin
lerna ERR! lerna
lerna ERR! lerna Fetching origin
lerna ERR! lerna
我尝试过创建〜/.ssh/id_rsa
文件中的文件,但仍然失败。
更新: 在更新之后,git_ssh
为git_ssh_command
错误已更改。
lerna info versioning independent
lerna info ci enabled
lerna ERR! Error: Command failed: git remote update
lerna ERR! Host key verification failed.
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!
我猜这是由于将主机添加到已知主机文件的提示。
更新 因此,正如预测的那样,添加git_ssh_command = ssh -i $ {key} -o“ stricthostkeychecking no” -l git
解决了问题。
I'm trying to use yarn bin lerna
command in pipeline for jenkins but it fails as it tries to fetch/update package git repository with ssh credentials.
Using below Jenkinsfile in multibranch project.
stages {
stage('Install NPM Deps') {
steps {
configFileProvider([configFile(
fileId: 'npm-auth',
targetLocation: '.npmrc'
)]) {
withCredentials([sshUserPrivateKey(credentialsId: 'cred-id', keyFileVariable: 'KEY')]) {
withEnv(['GIT_SSH=ssh -i ${KEY} -l git']) {
script {
docker.image("node").inside("-u0 -vnode_home:/.npm") {
sh 'yarn'
sh 'yarn clean --yes'
sh 'yarn bootstrap'
sh '$(yarn bin lerna) version ${VERSION}'
//sh 'yarn test'
//sh 'yarn deploy'
}
}
}
}
}
}
Error when running pipeline.
+ yarn bin lerna
+ /var/jenkins/workspace/test-lib/node_modules/.bin/lerna version patch
lerna notice cli v3.22.1
lerna info versioning independent
lerna info ci enabled
lerna ERR! Error: Command failed: git remote update
lerna ERR! error: cannot run ssh -l git: No such file or directory
lerna ERR! fatal: unable to fork
lerna ERR! error: Could not fetch origin
lerna ERR!
lerna ERR! Fetching origin
lerna ERR! lerna Command failed: git remote update
lerna ERR! lerna error: cannot run ssh -l git: No such file or directory
lerna ERR! lerna fatal: unable to fork
lerna ERR! lerna error: Could not fetch origin
lerna ERR! lerna
lerna ERR! lerna Fetching origin
lerna ERR! lerna
I've tried creating ~/.ssh/id_rsa
file out of the key but still fails.
UPDATE:
After updating GIT_SSH
to GIT_SSH_COMMAND
error has changed.
lerna info versioning independent
lerna info ci enabled
lerna ERR! Error: Command failed: git remote update
lerna ERR! Host key verification failed.
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!
I'm guessing it is due to prompt of adding host to known host file.
UPDATE
So as predicted adding GIT_SSH_COMMAND=ssh -i ${KEY} -o "StrictHostKeyChecking no" -l git
solved the issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
环境变量
git_ssh
(与git_ssh_command
)无法选择。请参阅主说:部分git
document ,该在某种程度上说:显然,您想使用
git_ssh_command
,而不是git_ssh
,此处。也就是说,这里还有其他奇怪的东西:
为什么
-i $ {key}
缺少?The environment variable
GIT_SSH
(as distinct fromGIT_SSH_COMMAND
) cannot have options. See the maingit
documentation, which says in part:Clearly you wanted to use
GIT_SSH_COMMAND
, notGIT_SSH
, here.That said, there's something else odd here:
Why is the
-i ${KEY}
missing?