After the repository accepts pushes: how to write the built-in pipeline YAML
This article explains how to write a .anguscicd.yaml that builds and tests on every push, after the repository already accepts pushes to AngusGit. After reading it, you can fill in the top-level fields, chain several jobs in order, choose when the pipeline runs, and reference a credential (a token or password saved on the platform) from a script without writing the token into a repository file.…
This guide explains how to create a .anguscicd.yaml file that automatically builds and tests code upon each push to the repository, without the need to push the changes again. After signing in to AngusGit, adding a runner, and editing the YAML file accordingly, you can write the YAML. The YAML file resides within the repository; either at the root level if there's a single pipeline, or under the .anguscicd/ directory if there are multiple pipelines.
Each YAML file represents a separate pipeline. The file name must be precise; formats like .gitlab-ci.yml or .angus-ci.yml will not be recognized as pipeline configurations.
Here's an example of a .anguscicd/01-basic-build.yaml file. This particular file runs a series of steps inside a node:20-alpine container every time a push occurs to the main or develop branches. The steps include displaying the environment, executing a Node.js application, and running its unit tests. Notably, the file doesn't include a checkout step since the platform automatically checks out the code before job execution.
Here's a breakdown of the YAML fields and their purposes:
- version 1: Indicates the configuration format version.
- name: basic-build-test: The name of the pipeline.
- triggers: A list of events that initiate the pipeline, here set to 'on: push'.
- branches: Specifies the branches that trigger the pipeline, in this case, 'main' and 'develop'.
- env: Defines environment variables, such as TZ (time zone) and APP_NAME (application name).
- pipeline: Specifies the build pipeline.
- build: A job identifier.
- runner.mode: Determines if the job runs inside a Docker container ('DOCKER') or directly on the host ('NATIVE').
- image: The Docker image address, required when using 'DOCKER' mode. The example uses the public image node:20-alpine.
- labels: Labels that allow the runner to select the job. The example uses 'linux' and 'docker'.
- steps: An array of job steps that are executed sequentially. Each step requires a name and a run command. The example includes steps to display the environment, run the Node.js application, and run unit tests.
For scenarios involving multiple jobs, such as the .anguscicd/04-monorepo-change.yaml file, the pipeline includes linting, building two services (service-a and service-b), and linting all modules. Each job can be triggered by a pull request targeting the main branch, with specific conditions applied to ensure only relevant modules are processed. The job configuration enables the use of modules to target specific directories, making the pipeline more efficient by avoiding unnecessary processing.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.