Trigger Gitlab-CI Pipeline only when there is a new tag

below could be more readable, see only:varibles@gitlab-ci docs with refs:tags

only:
  refs:
    - tags
  variables:
    - $CI_COMMIT_TAG =~ /^[Tt]icket-.*/

I recommend to use pattern in varibles-expression using commits

Example

build_api:
 stage: build
 script:
  - docker build --pull -t $CONTAINER_TEST_IMAGE .
  - docker push $CONTAINER_TEST_IMAGE
only:
  variables:
   - $CI_COMMIT_MESSAGE =~ /(\[pipeline\]|(merge))/     

Here i am saying that only execute that job when have [pipeline] or merge inside the commit. More info, here in gitlab


You need to use only syntax:

only:
  - tags

This would trigger for any Tag being pushed. If you want to be a bit more specific you can do:

only:
  - /Ticket\/ticket\_.*/

which would build for any push with the Ticket/ticket_ tag.