continuous-integrationcicddrone.io

Drone IO Difference between when and trigger?


My need is to run drone build when create a new tag in Gitea.

I can see two options there in Drone documentation. Please find below:

When

when:
      event: tag
      branch: master

Trigger

 trigger:
   branch:
     - master
   ref:
     include:
     - refs/tags/**

Please explain the difference and suggest which option is good to take.


Solution

  • Drone has a concept of "Pipelines" and "Steps".

    A pipeline is made up of one or more steps.

    The "when" is called a condition and is used to limit step execution - i.e. a pipeline with 4 steps defined may only run 2 steps based on conditions set. - condition docs

    Triggers are used to to limit whole pipeline execution - i.e. a pipeline may or may not run at all based on triggers set. - trigger docs

    It sounds to me that your use case is better served by a trigger - i.e. only run this build if a tag is created.