Access Repository source code in Dockerfile during build


Is there a way to access the repository source code within a docker build  as a git clone  inside the Dockerfile?

I tried something like that:

job("Build push Docker rails production image") {
host("Build and push") {
dockerBuildPush {

context = "docker"

file = "docker/base_images/rails/production/Dockerfile"

labels["vendor"] = "ABCDEFG"


val spaceRepo = ""


tags {






But the directory coming from JB_SPACE_WORK_DIR_PATH does not exists.

Any ideas?

Comment actions Permalink

The "JB_SPACE_WORK_DIR_PATH" environment variable should return the full path of the working directory. Please let me know if it works incorrectly in your case.

As for getting the repository source code, the below Help Articles explain how to do this:

If any further questions arise, please don't hesitate to post them.

Oleg Beriashvili
The Drive to Develop
Comment actions Permalink

Hi Oleg,

I have fitted JB_SPACE_WORK_DIR_PATH as an ARG to my build script. 


Now it works but the normal Dockerfile "COPY" doesn't work right for some reason.

It always searched for the directory like: "mnt/space/work/repo/mnt/space/work/repo" when i do "COPY ${JB_SPACE_WORK_DIR_PATH} /targetFolder/"


When i use "RUN cp -r ${JB_SPACE_WORK_DIR_PATH}/. /targetFolder/" it works perfectly.


Thanks for your help


Best regards


Please sign in to leave a comment.