#9738·concourse

fly: support `-i/--instance-var` for all commands that accept a pipeline reference

Author: benjaminguttmann-avtqCreated Sep 30, 2026Updated Sep 30, 2026

Summary

fly set-pipeline identifies an instanced pipeline via -p <name> plus one or more -i key=value flags. All other commands that target a pipeline, job, or resource only accept instance vars embedded in the reference string, e.g. -p my-pipeline/branch:main or -j my-pipeline/branch:main/my-job.

This inconsistency makes scripting awkward: the same instanced pipeline has to be addressed with two different syntaxes depending on the command, and values containing :, ,, or / require careful quoting in the embedded form.

Proposal

Add a repeatable -i/--instance-var NAME=YAML flag to every command that currently parses instance vars out of the pipeline reference, using the same format and semantics as set-pipeline:

bash
# existing (keeps working)
fly -t ci trigger-job -j my-pipeline/branch:main/unit

# new
fly -t ci trigger-job -j my-pipeline/unit -i branch=main
fly -t ci get-pipeline -p my-pipeline -i branch=main

Behaviour

  • Values are parsed as YAML; dotted keys are expanded (-i env.region=eu → {"env":{"region":"eu"}}), identical to set-pipeline.
  • Specifying instance vars both in the reference and via -i is an error (no implicit merging).
  • -i without a pipeline/job/resource reference is an error, as is -i combined with --all.
  • For commands with multiple possible targets (builds, hijack, clear-versions), -i applies to the one target that is set.
  • The existing name/key:value syntax remains fully supported (additive change).

Commands to update

Pipeline reference (-p/--pipeline)

  • archive-pipeline (optional -p, mutually exclusive with --all)
  • checklist
  • destroy-pipeline
  • expose-pipeline
  • get-pipeline
  • hide-pipeline
  • jobs
  • pause-pipeline (optional -p, mutually exclusive with --all)
  • paused-jobs
  • resources
  • unpause-pipeline (optional -p, mutually exclusive with --all)

Job reference (-j/--job)

  • abort-build
  • clear-task-cache
  • pause-job
  • rerun-build
  • schedule-job
  • trigger-job
  • unpause-job
  • watch

Resource / resource-type reference (-r)

  • check-resource
  • check-resource-type
  • clear-resource-cache
  • disable-resource-version
  • enable-resource-version
  • pin-resource
  • resource-versions
  • unpin-resource

Commands with more than one possible target

  • builds (-j or -p)
  • clear-versions (--resource or --resource-type)
  • hijack (-j or -c)

Special case (to be discussed)

  • execute (-j/--inputs-from): -i is already taken by --input, so only the long form --instance-var could be added.

Not affected

  • set-pipeline – already supports -i.
  • order-instanced-pipelines – -p already takes instance vars only.
  • -u/--url on watch/hijack – instance vars are taken from the URL.

Implementation notes

  • PipelineFlag, JobFlag, and ResourceFlag parse instance vars in UnmarshalFlag, which cannot see other flags. The -i values therefore need to be applied to the parsed atc.PipelineRef at the start of Execute().
  • A shared helper in fly/commands/internal/flaghelpers (e.g. ApplyInstanceVars(ref *atc.PipelineRef, pairs []YAMLVariablePairFlag) error) can enforce the rules above; the pairs-to-atc.InstanceVars conversion can be extracted from set_pipeline.go and reused there.
  • Tests: unit tests for the helper; integration tests in fly/integration mirroring the existing name/branch:master cases with -p name -i branch=master.
  • Docs: update the instanced pipelines section of the fly docs.

Open questions

  1. Should combining both syntaxes be an error (proposed) or should the vars be merged?
  2. Should execute --inputs-from get the long-only --instance-var flag?

Context

Discord Discussion: https://discord.com/channels/219899946617274369/604330872992432150/1554381930307395669