# Troubleshooting

> Find out why a pipeline did not run, why a job was left out, or why a run failed.
> **Available** in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its `.forge-ci.yaml` or `.xeonr-ci.yaml`. See [What is available](https://docs.branchd.run/branchd/pipelines#what-is-available).

Start with `branchd ci plan` for the same ref and event: it says, for every
job, whether it runs and why, and it is what branchd computes for the run.

```bash
branchd ci plan --ref main                     # a push to main
branchd ci plan --ref feature/x --event pull_request
branchd ci plan --ref v1.2.0                   # a tag
```

## The push was refused

`remote: … pipeline files: refused` with `file:line:column: message` lines
means the push changed a pipeline file (or a step or `packages.yaml` it
uses) so that it no longer compiles, for an event its `on:` lists. Nothing
else about the push was wrong. Run `branchd ci lint`, fix each line it
prints, commit, and push again.

- A file that was already broken in the same way before your push is a
  warning, not a refusal; only what your push breaks is refused.
- A problem that depends on another repository (a step it uses that you
  cannot read, a tag that does not exist) is a warning at push and refuses
  the run instead.
- If you may bypass the branch's rules and must push it anyway:
  `git push -o ci.allow-invalid`. The push is recorded as bypassed.

## No run started

- **The file is refused.** `branchd ci lint` prints the refusal, with the file
  and line. See [Refusals](https://docs.branchd.run/branchd/pipelines/errors).
- **`on:` does not match.** The plan's note says which filter did not:
  `on: push: branch dev matches none of branches main`. `on: [push]` without
  `branches` matches every branch and tag.
- **`paths:` matched nothing.** A pipeline with `paths:` runs only when a
  changed path matches. A tag ignores `paths`; a new branch counts as
  everything changed.
- **The commit's message says `[skip ci]`** (or `[ci skip]`, `[no ci]`,
  `[skip actions]`, `[actions skip]`), or the push used `-o ci.skip`. The
  run is listed as cancelled with the reason Skipped; re-run it to start it.
  See [Skip a push's pipelines](https://docs.branchd.run/branchd/pipelines/skip-a-run).
- **The file ends in `.yml`**, or is not in `.branchd/pipelines/`.
- **The repository also has an older CI file**, which is refused.
- **The repository is not switched to pipeline files yet.** branchd then runs
  `.forge-ci.yaml` or `.xeonr-ci.yaml` and ignores `.branchd/pipelines/`.
- **A pull request's branch** has an open pull request: its pushes run as the
  pull request's runs, so `on: pull_request` is what matters, not `on: push`.

## A job did not run

- **Its `if:` was false.** The plan prints the expression and that it was
  false. Remember that `branch` is a pull request's source branch, and
  `''` for a tag.
- **A job it needs failed.** A job runs only when its needs succeeded, unless
  its `if:` has `always()`.
- **It is waiting for a person** (`manual:`). Release it on the run's page or
  with `branchd run release <run> <job>`.
- **It is waiting for a lock** (`concurrency:`) another run holds.

## A step failed

- `branchd run failure <run>` shows the failed job and the end of its log;
  `branchd run log <run> <job>` the whole log.
- **Something set in one step is missing in the next.** Steps share a shell
  unless a step has `env`, `working-directory`, `shell`, `timeout` or
  `continue-on-error`, which give it a subshell of its own. A `cd` or an
  `export` there does not reach the next step.
- **`${{ }}` came out empty or literal in a script.** It is a variable, and
  single quotes stop the shell expanding it: use double quotes.
- **A service is not ready.** Services start with the job and are not waited
  for: poll the port first, as in
  [Test a Go service with a database](https://docs.branchd.run/branchd/pipelines/test-go-with-database).
- **A secret is empty.** The job must list it in `secrets:`. A protected
  secret reaches only runs of a person's push to a protected branch or tag,
  or a person's manual run of a protected branch's head, never a pull
  request, a schedule or a re-run of an older commit. A company's secret
  reaches only repositories of the company's teams.
- **An artifact is missing.** The job must `need` the job that made it, without
  `artifacts: false`, and the path must be one that job listed.

## A pull request cannot merge

- A required check that the pull request's run never reports keeps it from
  merging. A pipeline filtered by `paths:`, or a job whose `if:` is false on
  pull requests, never reports. See
  [Required checks](https://docs.branchd.run/branchd/pipelines/several-pipelines#required-checks).
- Renaming a pipeline or a job renames its check: update the branch rule.

## The run was cancelled

A newer run of the same unprotected ref cancels an older one. To keep them
both, put `concurrency: {cancel-in-progress: false}` at the top of the file.

Source: https://docs.branchd.run/branchd/pipelines/troubleshooting
