Changing the build intermediate paths for gitlab-runner I have a server pointed as ab12.xy24.com in which the projects are placed as:

 Path-1  
 /home/ab12/public_html/project1/*  
 /home/ab12/public_html/project2/*  
 ................................
 /home/ab12/public_html/projectn/{project-files}


I am using gitlab-runner for CI and CD. The build is being built as:

 Path-2  
 /home/ab12/build/{runner-token}/{commit-id}/{group-name}/project1/{project-files}
 /home/ab12/build/{runner-token}/{commit-id}/{group-name}/project1/{project-files}


I want the build path to be as in Path-1 style instead of path-2 style.



What have I tried?

I tried changing the build_path="path1" variable which only changed:

/home/ab12/build/{runner-token}/{commit-id}/{group name}/project1/{project-files}


to

/home/ab12/path1/{runner-token}/{commit-id}/{group-name}/project1/{project-files}


I cannot also use docker as due to its virtualization concept and takes much space, which is not desired.
Conceptually, this approach is not the way to go; the build directory is not a deployment directory, it's a temporary directory, to build or to deploy from, whereas on a shell executor this could be fixed.

So what you need is to deploy from that directory with a script as per gitlab-ci.yml below, to the correct directory of deployment.

stages:
- deploy

variables:
  TARGET_DIR: /home/ab12/public_html/$CI_PROJECT_NAME

deploy:
  stage: deploy
  script:
     mkdir -pv $TARGET_DIR
     rsync -r --delete ./ $TARGET_DIR
  tags:
    - myrunner


This will move your projectfiles in /home/ab12/public_html/

naming your projects as project1 .. projectn, all your projects could use this same .gitlab-ci.yml file.