Using a run file in your CI pipeline

One of my earliest daily emails was about run files - files that contain Bash functions that combine or simplify project-specific tasks.

In Drupal projects, these could be to execute Composer or Drush commands, connect to the database, or run automated tests.

For my CI pipelines, I like to use a function called ci:test that contains all the commands to run in the pipeline.

This keeps the pipeline configuration as simple and agnostic as possible.

It also makes it easy for people to read and, because it's a bash file, it will run anywhere without any additional tools.

For an example, see my Drupal Docker example repository.

Here's the thing

The main advantage, though, is being able to run the pipeline locally, if you need to.

Maybe you need to debug a failure in the pipeline or you want to test a change to the pipeline locally before pushing it.

By using a command in a run file, doing so is as simple as running that one command.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.