Predefined variables

GitLab offers many predefined variables

Most describe the current job, stage and pipeline

Some describe the GitLab server

Some help interacting with the GitLab server

Hands-On

  1. Remove variables directive

     git checkout origin/160_gitlab_ci/020_variables/predefined -- '*'
    

  2. Update build command:

     go build \
         -ldflags "-X main.Version=${CI_COMMIT_REF_NAME}" \
         -o hello \
         .