A small PHP project for Continuous Delivery integrated with GitLab.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
Go to file
Joshua Westerheide 3b69e51b7a Updated composer json and updated composer package 7 years ago
logs Added log directory 7 years ago
.gitignore Added log directory 7 years ago
LICENSE * Added License file 7 years ago
README.md Updated version information 7 years ago
composer.json Updated composer json and updated composer package 7 years ago
composer.lock Updated composer json and updated composer package 7 years ago
deploy-config.example.php Added cleanup option and set defaults. Also updated a default value of another option. 7 years ago
deploy.php Updated version information 7 years ago


Small PHP GitLab CD v0.2.1

This project contains a simple script to deploy GitLab artifacts.

Build artifcats can be build using the GitLab CI (more here).

This project was heavily inspired by simple-php-git-deploy.


  • You need php >= 5.6.
    • Optionally, composer is required for creating project with composer.
    • Optionally, sendmail is required to send notifications on errors.
  • curl is required to download artifacts from gitlab using the api,
  • unzip is required to extract the artifacts and finally
  • rsync is required to move files from cache to the defined target.
  • You also need read and write permissions to all defined directories (See Configuration).


  • Clone this repository: git clone https://github.com/jdoubleu/small-php-gitlab-cd.git or
  • Use Composer to create a new project: composer create-project jdoubleu/small-php-gitlab-cd


Copy the deploy-config.example.php to deploy-config.php. The deploy script looks for a file with its name appended with "config" so you can create as much configurations as you want.

Have a look at the comments in the config file(s)!


For WebHook's

Go into your GitLab instance (or to gitlab.com), then go to the settings of your project and create a Webhook. Select only Build events and enter the url with appended value of secret_token in URL field.

For example: https://cd.example.com/deployment/?secret_token=AverySecretTokenOnlyYouShouldKnow

Now you're done! Every time a build happens your script is called. Only on fitting and successful builds your script tries to deploy the artifacts.

From CLI

Run the deploy script manually using your php interpreter like this:

/usr/bin/php path/to/deploy.php -p 1 -b 10


  • -p determines the project id (optional if no project id is given in config) and
  • -b the build id


If the script failed check the error log!

Some errors are not displayed in the error log:

  • When the API request returned a 401 Unauthenticated
  • When the project and/or build cannot be found
  • When there is no artifact for the given build

Please keep this in mind! Try to check this by executing the curl command manually on your shell.


You are welcome to contribute to this project. Either in creating issues or submitting code.

Please checkout develop branch. If you want to introduce a new feature you should create a feature branch out of the develop branch. If you are finished just create a PR on develop.

Thank You!