Build Pipelines series: Configure your pipeline stages to save credits

In our continued exploration of Bitrise's features for optimizing CI/CD pipelines, we delve into a strategy that enhances efficiency and conserves your credits: configuring your pipeline stages with abort_on_fail. This functionality is pivotal for projects looking to parallelize processes without incurring unnecessary credit usage, especially when certain stages in your pipeline are contingent on the success of others.

What to expect in this series:

Parallel processing: Why you need to master `abort on fail`

Parallelization in CI/CD pipelines is a game-changer, allowing multiple workflows to run simultaneously, thereby slashing wait times significantly. From dividing your test suite across different workflows to concurrently building frontend and backend assets, parallelization can accelerate your deployment process notably. Yet, this approach comes with its complexities, particularly in handling failures in parallel workflows. 

With parallelized tests, it makes sense to execute every one of them to see all errors if there are any. However, with packaging assets, it might not be useful to go on with packaging the frontend assets if we know the backend packaging failed. But they run in parallel. What can we do? That’s why we created the abort_on_fail pipeline configuration.

Configuring abort_on_fail for efficient credit use: A step-by-step guide

Step 1: Setting up your pipeline

Imagine a pipeline designed to package frontend and backend assets in separate workflows, followed by a deployment stage. This setup, while efficient, poses a challenge if one of the packaging workflows fails, as you might not want to proceed with the deployment or continue consuming credits on failed asset packaging. 

For this reason, we’re going to start with a simple workflow where the one and only stage runs multiple workflows in parallel.

pipelines:
 my-awesome-pipeline:
  stages:
  - package-stage: {}
  - deploy-stage: {}
stages:
 package-stage:
   workflows:
   - package-frontend: {}
   - package-backend: {}
 deploy-stage:
   workflows:
   - deploy: {}
workflows:
 package-frontend: {}
 package-backend: {}
 deploy: {}

Step 2: Implementing abort_on_fail

Now, let’s introduce the abort_on_fail configuration within your pipeline stages. By applying this to the package-stage, you ensure that if the package-frontend or package-backend workflows fail, all subsequent workflows inside the package-stage are halted, preventing further credit expenditure on a faulty deployment. 

package-stage:
 abort_on_fail: true  
 workflows:
 - package-frontend: {}
 - package-backend: {}

YML Configuration

Below is an example YML configuration demonstrating how to apply the abort_on_fail attribute within your pipeline to ensure that failures in parallel workflows can effectively conserve your Bitrise credits.

---
format_version: '13'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: android

pipelines:
  my-awesome-pipeline:
    stages:
    - package-stage: {}
    - deploy-stage: {}

stages:
  package-stage:
    abort_on_fail: true
    workflows:
    - package-frontend: {}
    - package-backend: {}
  deploy-stage:
    workflows:
    - deploy: {}

workflows:
  package-frontend: {}
  package-backend: {}
  deploy: {}

meta:
  bitrise.io:
    stack: linux-docker-android-20.04
    machine_type_id: elite

The impact of abort_on_fail on your CI/CD strategy

Incorporating abort_on_fail into your pipeline configuration allows you to align your CI/CD process with a more sustainable, credit-efficient approach. This method saves valuable Bitrise credits and ensures that your team focuses on resolving issues promptly without unnecessary resource consumption.

Conclusion

The abort_on_fail in Bitrise pipelines represents a critical balance between maintaining rapid development cycles and optimizing resource usage. As we push towards more efficient and cost-effective CI/CD practices, features like these play a vital role in managing the operational costs of software development without compromising on quality or speed.

Ready to optimize your Bitrise workflows and save credits? Dive into our comprehensive Pipelines documentation and start configuring your pipelines with best practices in mind. Not a Bitrise user? Start for free today.

Get Started for free

Start building now, choose a plan later.

Sign Up

Get started for free

Start building now, choose a plan later.