Jenkins linking to my local git repository Jenkins linking to my local git repository jenkins jenkins

Jenkins linking to my local git repository


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.


Access local git repository in Jenkins docker container

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 Volumes for more details).

To mount your local git repository folder to a Jenkins container run the container with an additional -v or --volume flag.

The basic docker run statement from the official docker image documentation would then look like.

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.

Then you can simply access your git repository via the file protocol.

file://<MOUNT_POINT_IN_CONTAINER>

No need to use ssh.


If you run Jenkins within Docker, one possible solution would be via SSH:

ssh://user@IP_of_your_host/path_to_your_project/project_name