GitLab CI/CD pipeline that runs only when a tag is created from the master

You can set up a GitLab CI/CD pipeline to run only when a new tag is pushed to the master branch by using the only keyword in the .gitlab-ci.yml file. Here's an example of how you can do this:

stages:

  - build

  - deploy


build:

  stage: build

  script:

    # build commands

  only:

    refs:

      - tags

    changes:

      - "master"


deploy:

  stage: deploy

  script:

    # deploy commands

  only:

    refs:

      - tags

    changes:

      - "master"


In this example, the build and deploy jobs will only run when a new tag is pushed to the master branch. The only keyword specifies that the job should only run under certain conditions. The refs value of tags specifies that the job should only run when a new tag is created. The changes value of master specifies that the job should only run when changes are pushed to the master branch.

Comments

Popular posts from this blog

Unable to publish npm package

Robot Framework pipeline with GitLab CI / CD