Skip to content

Add support for CI Job Inputs interpolation

GitLab users need the ability to retry CI jobs with new parameter values without having to modify the entire pipeline configuration. Currently, users must rely on CI variables which have complex precedence rules and security concerns.

The Rails side will be adding a new inputs keyword at the job level that allows users to define dynamic values with explicit types and defaults. The Runner needs to support interpolating these job inputs using the ${{ job.inputs.input_name }} syntax before executing job scripts.

Proposal

Add support for job inputs interpolation in gitlab-runner by:

  1. Receiving job inputs in the job payload - Rails will optionally send job inputs in the JobResponse
  2. Interpolating job inputs using step-runner library - Use the existing step-runner Go library to ensure forward compatibility with CI Steps
  3. Evaluation order - Evaluate job inputs before job variables to give inputs higher precedence
  4. Syntax support - Support ${{ job.inputs.input_name }} syntax (with optional whitespace: ${{ job.inputs.input_name }})

Supported input types

  • string
  • number
  • boolean
  • array
  • struct

Supported keywords for interpolation

Job inputs should be interpolated in the same locations where job variables are currently expanded:

  • after_script, before_script, script
  • artifacts:name, artifacts:paths, artifacts:exclude
  • cache:key, cache:paths, cache:policy
  • image
  • services, services:name

Constraints

  • Expression limitations: No nested expressions (e.g., ${{job.inputs.${{job.inputs.var}}}})
  • Context restrictions: Only job.inputs context available, no access to other step contexts like steps, env, output_file, etc.
  • Backward compatibility: Must use step-runner library for interpolation to ensure compatibility with future CI Steps integration

Example JSON payload

Rails will include job inputs in the job payload sent to Runner:

{
  "inputs": [
    {
      "key": "username",
      "value": {
        "type": "string",
        "content": "fred"
      }
    },
    {
      "key": "password",
      "value": {
        "type": "string",
        "content": "123456"
      }
    },
    {
      "key": "age",
      "value": {
        "type": "number",
        "content": 1
      }
    },
    {
      "key": "likes_spaghetti",
      "value": {
        "type": "boolean",
        "content": false
      }
    },
    {
      "key": "friends",
      "value": {
        "type": "array",
        "content": [
          "bob",
          "sally"
        ]
      }
    },
    {
      "key": "friends",
      "value": {
        "type": "struct",
        "content": {
          "line1": "42 Wallaby Way",
          "line2": "Sydney"
        }
      }
    }
  ]
}

Out of scope

  • Sensitive inputs: Masking of sensitive job inputs (to be handled in separate issue)
  • Advanced expressions: Complex expression features beyond basic interpolation
  • Job outputs: This issue only covers inputs, not outputs

References

Edited by Cameron Swords