Answers: <p>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 <strong>from</strong>, whereas on a shell executor this could be fixed.</p>
  
  <p>So what you need is to deploy from that directory with a script as per <code>gitlab-ci.yml</code> below, to the correct directory of deployment.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>This will move your <code>projectfiles</code> in /home/ab12/public_html/</p>
  
  <p>naming your projects as <code>project1</code> .. <code>projectn</code>, all your projects could use this same <code>.gitlab-ci.yml</code> file.</p>
  
Answers: CC BY-SA 3.0
Answers: 2017-11-24T05:53:58.887Z
Answers: can you please explain its working for files handled with .gitignore... How would '''rsync help this'''
Answers: Krishna Chalise
Answers: CC BY-SA 3.0
Answers: 2017-11-25T04:54:28.027Z
Answers: @Wildfire not sure if I understand the question. `.gitignore` is used for your local tree, meaning items in `.gitignore` are not committed ( git commit ), thus also not pushed to the git repository and thus also not present in the `CI_PROJECT_DIR`.
Answers: Danny Goossen
Answers: CC BY-SA 3.0
Answers: 2017-11-27T11:23:44.937Z
Answers: I am quite sure you know my question. my last comment has just my illusion... thanks
Answers: Krishna Chalise
Answers: CC BY-SA 3.0
Answers: 2017-05-31T02:40:59.890Z
Answers: 2017-05-31T12:20:05.913Z
Answers: 2017-05-31T12:20:05.913Z
Answers: Danny Goossen
Body: <p>I have a server pointed as ab12.xy24.com in which the projects are placed as:</p>
  
  <pre><code> Path-1  
   /home/ab12/public_html/project1/*  
   /home/ab12/public_html/project2/*  
   ................................
   /home/ab12/public_html/projectn/{project-files}
  </code></pre>
  
  <p>I am using gitlab-runner for CI and CD. The build is being built as:</p>
  
  <pre><code> 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}
  </code></pre>
  
  <p>I want the build path to be as in Path-1 style instead of path-2 style.</p>
  
  <hr>
  
  <p>What have I tried?</p>
  
  <p>I tried changing the <code>build_path="path1"</code> variable which only changed:</p>
  
  <pre><code>/home/ab12/build/{runner-token}/{commit-id}/{group name}/project1/{project-files}
  </code></pre>
  
  <p>to</p>
  
  <pre><code>/home/ab12/path1/{runner-token}/{commit-id}/{group-name}/project1/{project-files}
  </code></pre>
  
  <p>I cannot also use docker as due to its virtualization concept and takes much space, which is not desired.</p>
  
Comments: CC BY-SA 3.0
Comments: 2017-05-06T16:40:13.013Z
Comments: As far as I know you can't (to avoid race conditions between 2 builds). But if you're sure of uniqueness of builds,  a symlink from path1 to path2 in the before section should do no?
Comments: Tensibai
Tags: <continuous-integration><continuous-deployment><gitlab>
Title: Changing the build intermediate paths for gitlab-runner
UserDisplayName: Krishna Chalise
ThreadText: # Changing the build intermediate paths for gitlab-runner
  
  (Asked by: username_0 on 2017-05-05)
  
  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.
  
  **Tags:** continuous-integration, continuous-deployment, gitlab
  
  > **Comments:**
  > **username_1**: As far as I know you can't (to avoid race conditions between 2 builds). But if you're sure of uniqueness of builds,  a symlink from path1 to path2 in the before section should do no?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-05-31. Score: 10
  
  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.
  
  > **Comments:**
  > **username_0**: can you please explain its working for files handled with .gitignore... How would '''rsync help this'''  
  > **username_2**: @Wildfire not sure if I understand the question. `.gitignore` is used for your local tree, meaning items in `.gitignore` are not committed ( git commit ), thus also not pushed to the git repository and thus also not present in the `CI_PROJECT_DIR`.  
  > **username_0**: I am quite sure you know my question. my last comment has just my illusion... thanks  
  
  ---
  
  