Gitlab CICD pipeline

Hello Experts,

I am new to Gitlab world.
I am using GitLab Community Edition 8.9.6 ba3d01c .
I got an assignment to configure Gitlab CICD pipeline.
Assignment is like, whenever user commits code to the master branch, it will automatically get deployed to our stating server.
Right now there is no production server in place.
Please help me with any document or link available to achieve this.

Thank you in advance.

Please help.


can you share more insights on your code basis? Is it for example a PHP application which needs to run on a web server, or are we talking about a Go daemon which should run on the staging environment?

Also, how would you deploy the staging server, e.g. with Ansible/Terraform?

Either way, I’d suggest to start simple.

  • Install a GitLab runner & Docker, register it with the GitLab server
  • Create a small .gitlab-ci.yml config in your repository which runs a small script like this:
image: centos:7

    - echo "Hello from GitLab CI"
    - exit 1
  • Fix it by modifying exit 1 to exit 0
  • Having learned more about GitLab CI, now actually do something with the code
    • Limit the execution to the master branch
image: centos:7

    - echo "Hello from GitLab CI"
    - exit 0
    - master
  • E.g. install Ansible, add SSH secrets and deploy the code to your staging VM

In terms of documentation, please hop over there:

You might also dive into our open source workshop for GitLab:


Hi Michael,

Thank you for your response.
It is an PHP application which runs on a Apache web server.
As right now I am in learning phase, I am not using Ansible/Terraform to deploy code on to the staging server. I am planning to use simple rsync command to do it.


then keep things simple and then adopt the examples above:

  • Add an SSH keypair into your config with using the SSH_PRIVATE_KEY variable populated in your project settings
  • Make sure that the public key is stored on the remote VM’s /home/username/.ssh/authorized_keys
  • Add the rsync command to the script section. Highly likely you just want to sync the whole git repository content to the server
  • Do some post steps, e.g. with running a script via SSH to restart the webserver

Here’s some howtos in this regard: