Should a pipeline fail if early termination is desired?



  • Normally a pipeline breaks down into stages such that each stage has one or more jobs. In order to stop the pipeline from running conditionally, you simply fail that stage of the pipeline.

    For example let's assume I have a pipeline with four stages,

    [Build] -> [Test] -> [Version Bump] -> [Publish]
    

    Now, let's assume the Version Bump may or may not bump the version number which means the Publish stage may or may not run. In order to model this in GitLab we would normally fail the Version Bump stage at the point that we know the Publish should not run. But one of my co-workers does not like the term "fail" here.

    Given the above circumstance, is it a normal flow to have a stage pass unconditionally, and to have a subsequent stage conditionally execute?

    Or, is the pipeline failing just the way in which a pipeline should conditionally terminate?



  • I'm going to take an opinionated approach based on the https://12factor.net

    Typically, stages should execute a function, with predictable inputs and outputs.

    If stage 3 executes the function "compute next version" and the output of that function is "The next version is the same as the previous version", then even if there is no version change, the stage has successfully executed it's function. Again, the inputs and outputs are predictable.

    Similarly for the fourth stage (Publish). If you have built the software, but the version hasn't changed, you still have a new artifact. It has a different build, but the same version. This could happen if for example you change the environment or configuration it's deployed into. As the 12factor app puts it:

    The twelve-factor app uses strict separation between the build, release, and run stages. https://12factor.net/build-release-run

    So your publish function should deliver a new artifact, with the same version, but different build metadata (ie pipeline execution number, date, etc.)

    In either case, no you do not need to fail the pipeline (nothing has broken, no changes are necessary) and yes you should execute the last stage, which should implement the actual deployment strategy you use.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2