Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / azure

Pipeline jobs declare a timeout

azure/job-timeout-set@v1

Every job declares how long it may run, and none of them asks for the maximum, so a hung job is cut off rather than holding an agent.

Idazure/job-timeout-set
Versionv1
Categoryazure
Default severityinfo
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectsazure

Collectors

This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.

CollectorGathersInputs it is given
azureThe Azure Pipelines YAML the repository carries, read as Azure writes it: what starts a run, the stages and jobs it declares, the pool each job lands on and how long it may run, and every task a step reaches for with the version it asks for, alongside the macro, template and runtime expressions a script interpolates. Names and shapes only, never a secret, an input value or a variable value.pipelines

The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.

Configuration

json
{
  "guardrails": {
      "failOn": "error",
      "comment": true,
      "checks": [
          {
              "use": "azure/job-timeout-set@v1",
              "severity": "info",
              "with": {
                  "pipelines": "azure-pipelines*.yml,azure-pipelines*.yaml",
                  "maxMinutes": "60"
              },
              "exemptions": []
          }
      ]
  }
}

Inputs

InputDescriptionDefaultEnvironment variable
pipelinesComma separated globs naming the Azure Pipelines definitions to read.azure-pipelines*.yml,azure-pipelines*.yamlGUARDRAIL_INPUT_PIPELINES
maxMinutesLongest timeout accepted. A job declaring more than this is treated as declaring none.60GUARDRAIL_INPUT_MAXMINUTES

How to fix

Declare one on each job:

yaml
jobs:
  - job: build
    timeoutInMinutes: 15
    steps:
      - script: ./gradlew check

A job that declares none takes 60 minutes on a Microsoft hosted agent and runs forever on a self hosted one. timeoutInMinutes: 0 asks for the maximum, which on a self hosted agent is no limit at all, so it is the one value worth reading as declaring nothing.

Buildnote Limited
Registered in England and Wales, Reg: 16140412