A manual pipeline with inputs
Let a person start a pipeline by hand, with typed inputs that the jobs read.
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.yamlor.xeonr-ci.yaml. See What is available.
# .branchd/pipelines/release.yaml
# Started by hand, with typed inputs. On any other event an input reads its
# default, so the if: below works everywhere.
name: Release
on:
manual:
inputs:
version:
type: string
required: true
description: The version to tag, such as 1.4.0.
channel:
type: choice
options: [stable, beta]
default: beta
dry_run:
type: boolean
default: true
jobs:
release:
image: alpine/git:2.47
env:
CHANNEL: ${{ inputs.channel }}
steps:
- run: echo "releasing ${{ inputs.version }} to $CHANNEL"
- if: ${{ !inputs.dry_run }}
run: ./scripts/tag-release.sh "${{ inputs.version }}"
on: manuallets a person start this pipeline.inputs:declares what they give, each with atype:string(the default),boolean,numberorchoice(which needsoptions).default,requiredanddescriptionare optional.- Checked before the run starts. A value of the wrong type, a
choiceoutside its options, an input the file does not declare, or a missing required input with no default refuses the run. ${{ inputs.<name> }}reads one, inif:,env:,run:andwith:. In arun:it is a variable, never shell text.- On every other event an input reads its default, else
'',falseor0, so anif:that reads one works for every event the file has. - An input declared under both
manualandtriggermust have one type.
Start it
From a terminal, inside the clone (a run of main's current commit):
branchd run start main --pipeline Release --input version=1.4.0 --input channel=stable --input dry_run=falseFrom a job or a script, with the API (a job needs permissions: {pipelines: write}, see The job token):
curl -fsS -H "Authorization: Bearer $BRANCHD_TOKEN" -H 'Content-Type: application/json' \
"$BRANCHD_API_URL/xeonr.forge.v1.RunService/CreateRun" \
-d '{"repository":"acme/app","ref":"main","pipeline":"Release","inputs":{"version":"1.4.0","channel":"stable","dry_run":"false"}}'--pipeline is the pipeline's name: (else its file name without
.yaml); its on: must list manual. Inputs are sent as text and checked
against their types: a refusal exits 2 and says which input and why.
To see what it would run first:
branchd ci plan --event manual --pipeline Release --input version=1.4.0Not yet available (cli 0.39.0):
branchd run start --pipeline … --input …is in the next CLI release; until then use the API form above.
Not yet available (console): the console's Run pipeline starts a run of a branch only, with no pipeline or inputs to choose.