2 issues with GitLab CI

Issue 1

I have a .gitlab-ci.yml with ‘only: trigger’, but when I specify my trigger token in an environment variable, the task doesn’t run. I suppose issue #2 could be the cause.

aptly:
  stage: deploy
  only:
    - trigger
  script:
    - apt-get update
    - apt-get --no-install-recommends -y install bash curl jq ruby ruby-dev rubygems
    - gem install aptly_cli --no-rdoc --no-ri
    - chmod +x ${CI_PROJECT_DIR}/.gitlab-ci/upload.sh
    - chmod +x ${CI_PROJECT_DIR}/.gitlab-ci/lib-aptly.sh
    - bash ${CI_PROJECT_DIR}/.gitlab-ci/upload.sh

Issue 2

When executing any bash script in the deploy stage, I get errors about missing variables:

Try 1:

$ bash ${CI_PROJECT_DIR}/.gitlab-ci/upload.sh
$PROJECT is missing
ERROR: Job failed: exit code 1

Try 2 (after adding $PROJECT to environment variables manually):

$ bash ${CI_PROJECT_DIR}/.gitlab-ci/upload.sh
$STAGE is missing
ERROR: Job failed: exit code 1

GitLab is supposed to pass these variables, right?