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

后端 未结 3 929
旧时难觅i
旧时难觅i 2021-01-05 15:32

I have following gitlab-ci conf. file:

before_script:
  - echo %CI_BUILD_REF%
  - echo %CI_PROJECT_DIR%

stages:
  - createPBLs
  - build
  - package


creat         


        
相关标签:
3条回答
  • 2021-01-05 15:48

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

      only:
        refs:
          - tags
        variables:
          - $CI_COMMIT_TAG =~ /^[Tt]icket-.*/
    
    0 讨论(0)
  • 2021-01-05 15:56

    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.

    0 讨论(0)
  • 2021-01-05 16:00

    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

    0 讨论(0)
提交回复
热议问题