Jenkins 链接到我的本地 git 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10498554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins linking to my local git repository
提问by Zhivko Draganov
I'm new to Jenkins and git too. I created a remote repository at github.com
and made a local copy of it.
Then I want to link it through Jenkins. I installed needed plugins for git integration, but I don't know what my local Repository URL is to set it when configuring the new project. Could someone help me where to find it?
我也是 Jenkins 和 git 的新手。我创建了一个远程存储库github.com
并制作了它的本地副本。
然后我想通过詹金斯链接它。我安装了 git 集成所需的插件,但我不知道在配置新项目时我的本地存储库 URL 是什么来设置它。有人可以帮我在哪里找到它吗?
回答by Balakrishnan Ramaswamy
In this case, the URL should start with the file protocol followed by the path to the repository. E.g., file:///home/rbkcbeqc/dev/git/gitsandbox
.
在这种情况下,URL 应以文件协议开头,后跟存储库的路径。例如,file:///home/rbkcbeqc/dev/git/gitsandbox
。
回答by Paul Wasilewski
Access local git repository in Jenkins docker container
访问 Jenkins docker 容器中的本地 git 存储库
In case somebody wants to connect to a local git repository from a Jenkins which runs in a docker container I would recommend to mount the local git repository folder to the docker image via the Volumes flag (see Use Volumesfor more details).
如果有人想从在 docker 容器中运行的 Jenkins 连接到本地 git 存储库,我建议通过 Volumes 标志将本地 git 存储库文件夹挂载到 docker 映像(有关更多详细信息,请参阅使用卷)。
To mount your local git repository folder to a Jenkins container run the container with an additional -v
or --volume
flag.
要将本地 git 存储库文件夹挂载到 Jenkins 容器,请运行带有附加-v
或--volume
标志的容器。
The basic docker run statement from the official docker image documentation would then look like.
来自官方 docker 镜像文档的基本 docker run 语句看起来像这样。
docker run -p 8080:8080 -p 50000:50000
-v <PATH_TO_LOCAL_GIT_REPO>:<MOUNT_POINT_IN_CONTAINER>:ro
jenkins/jenkins:latest
The :ro
option is optional. It will mount the volume as read-only. So you won't be able to write to the repos from the container.
该:ro
选项是可选的。它将卷挂载为只读。因此,您将无法从容器写入存储库。
Then you can simply access your git repository via the file protocol.
然后你可以简单地通过文件协议访问你的 git 存储库。
file://<MOUNT_POINT_IN_CONTAINER>
No need to use ssh.
无需使用 ssh。
回答by Chuan
If you run Jenkins within Docker, one possible solution would be via SSH:
如果您在 Docker 中运行 Jenkins,一种可能的解决方案是通过 SSH:
ssh://user@IP_of_your_host/path_to_your_project/project_name
回答by SangminKim
If you did clone a remote repository into local where Jenkins
is running.
如果您确实将远程存储库克隆到Jenkins
正在运行的本地。
You can just put the path of the local repository then it will work.
您可以只放置本地存储库的路径,然后它就会工作。
For example, /home/username/local_repository_path
.
例如,/home/username/local_repository_path
。