I am just writing a perl module for CPAN. The source-code is hosted on my own gitlab-server. When committing code it should be immediately tested by a worker (called gitlab-runner) which waits for the programmer's commit. The gitlab-runner checks out the commit and is going to test the code.

My own traffic-light

The webserver is running on a Raspberry Pi. When I click on one of the buttons the light changes:

What really happens when I click onto the red picture, this URL gets called: http://ampel.buchabfrage.de/red. A CGI-script runs the action with the traffic-light.

This whole thing can only run on my developmentserver, so I have to set some environment-variables on the gitlab-server for this special project:

And a file in my project ./myproject/.gitlab-ci.yml (filename was defined by the gitlab-team and must be exactly the same):

# Do these stages in CI
# Testing environment in Debian v9

# Showing success on my trafficlight which is switched by a webserver
# To make the trafficlight showing a signal you have
# to define gitlab-variables for this project
# (gitlab-Webserver/this_project/Settings/CI/Variables):
# CI_TRAFFICLIGHT_GREEN_URL=http://mytrafficlight.local/green
# CI_TRAFFICLIGHT_YELLOW_URL=http://mytrafficlight.local/yellow
# CI_TRAFFICLIGHT_RED_URL=http://mytrafficlight.local/red

# tags: perl <- this ci-config is only for runners which are able to run perl
#               the runner itself decides that
stages:
  - build
  - test
  - showsuccess

trafficlight_yellow:
  stage: build
  tags:
    - perl
  only:
    variables:
      - $CI_TRAFFICLIGHT_YELLOW_URL =~ /^http/
  when: always
  script:
    - curl $CI_TRAFFICLIGHT_YELLOW_URL

prove:
  stage: test
  tags:
    - perl
  script:
    - prove -v t/

trafficlight_green:
  stage: showsuccess
  tags:
    - perl
  only:
    variables:
      - $CI_TRAFFICLIGHT_GREEN_URL =~ /^http/
  when: on_success
  script:
    - curl $CI_TRAFFICLIGHT_GREEN_URL

trafficlight_red:
  stage: showsuccess
  tags:
    - perl
  only:
    variables:
      - $CI_TRAFFICLIGHT_GREEN_URL =~ /^http/
  when: on_failure
  script:
    - curl $CI_TRAFFICLIGHT_RED_URL

Gitlab shows what it is doing here: