简体   繁体   English

当使用 jenkins 管道在 docker 容器中运行时,我们如何为 npm 设置 StrictHostKeyChecking=no?

[英]How do we set StrictHostKeyChecking=no for npm when running in docker container using jenkins pipeline?

I am trying to install npm modules from private repository in docker container from a jenkins pipeline .我正在尝试从jenkins 管道的 docker 容器中的私有存储库安装npm模块。 I have followed this blog: https://sanderknape.com/2019/06/installing-private-git-repositories-npm-install-docker/ and used the docker buildkit option.我关注了这个博客: https://sanderknape.com/2019/06/installing-private-git-repositories-npm-install-docker/并使用了 docker buildkit 选项。 My problem is in the ssh configuration for StrictHostKeyChecking=no .我的问题出在StrictHostKeyChecking=no的 ssh 配置中。

When I run this command in docker it is successful as it adds the host to known_hosts当我在 docker 中运行此命令时,它会成功,因为它将主机添加到 known_hosts

RUN --mount=type=ssh,id=github GIT_SSH_COMMAND="ssh -vvvT -o StrictHostKeyChecking=no" git clone git@github.****

But while running this command, I get Host Verification failed error:但是在运行此命令时,出现主机验证失败错误:

RUN --mount=type=ssh,id=github GIT_SSH_COMMAND="ssh -vvvT -o StrictHostKeyChecking=no" npm install git+ssh://git@github.****

Also, how do we pass ssh-agent configured in jenkins pipeline to a docker container?另外,我们如何将 jenkins 管道中配置的 ssh-agent 传递给 docker 容器?

Got it resolved at last.终于解决了。 The problem was that git and npm were using different home directories for cloning.问题是 git 和 npm 使用不同的主目录进行克隆。

Git was using root user and so had permission to check the /root/.ssh folder but somehow npm was using the directory /home/user/.ssh and was getting some permission related problems. Git 使用 root 用户,因此有权检查 /root/.ssh 文件夹,但不知何故 npm 使用目录 /home/user/.ssh 并遇到一些与权限相关的问题。

After doing a simple做了一个简单的之后

RUN npm config set cache /root

I was able to successfully execute the below command without any problems.我能够毫无问题地成功执行以下命令。

RUN --mount=type=ssh,id=github GIT_SSH_COMMAND="ssh -vvvT -o StrictHostKeyChecking=no" npm install git+ssh://git@github.****

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jenkins Pipeline Docker -- 容器未运行 - Jenkins Pipeline Docker -- Container is Not Running 我们如何在 jenkins docker 容器中安装 npm pdf-parse 库 - How do we install npm pdf-parse library in jenkins docker container 如何使用 Jenkins 管道在 docker 容器中挂载 Jenkins 工作区 - How to mount Jenkins workspace in docker container using Jenkins pipeline 使用 Jenkins 管道在 Jenkins 上构建 docker 容器 - Building a docker container on Jenkins using a Jenkins Pipeline 詹金斯管道/码头:詹金斯似乎没有在容器内运行 - Jenkins pipeline/docker :Jenkins does not seem to be running inside a container 如何使用 jenkins 管道脚本创建 docker 容器 - how to create docker container using jenkins pipeline script 使用“Docker 外部的 Docker”设置时,无法连接到 Jenkins 管道中的 docker 容器 - Unable to connect to docker container in Jenkins pipeline when using “Docker outside of Docker” setup 使用 Docker Z2E54334C0A5CE2ADAZE3E5A5845DF3AB3 构建 docker 映像时未找到 Docker - Docker not found when building docker image using Docker Jenkins container pipeline 如何访问在 Ubuntu Docker 容器中运行的 Jenkins 的前端? - How do I access the frontend of Jenkins running in a Ubuntu Docker container? 使用Docker Pipeline插件时,在Jenkins中停止和删除docker容器的正确方法是什么? - What is the proper way to stop and remove a docker container in Jenkins when using Docker Pipeline Plugin?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM