Jenkins · CI/CDintermediate

Jenkins Pipeline Definition (JSON)

A JSON description of a Jenkins CI pipeline — parameters, ordered stages and steps — for tools that generate Jenkinsfiles from structured data.

jenkinscicdpipelineautomation

Preview

{
  "agent": "any",
  "parameters": [
    {
      "type": "boolean",
      "name": "RUN_TESTS",
      "defaultValue": true
    }
  ],
  "environment": {
    "CI": "true"
  },
  "stages": [
    {
      "name": "Build",
      "steps": [
        "npm ci",
        "npm run build"
      ]
    },
    {
      "name": "Test",
      "when": "params.RUN_TESTS == true",
      "steps": [
        "npm test"
      ]
    },
    {
      "name": "Deploy",
      "when": "branch == 'main'",
      "steps": [
        "./deploy.sh production"
      ]
    }
  ],
  "post": {
    "always": [
      "echo \"pipeline finished\""
    ],
    "failure": [
      "echo \"notify the team\""
    ]
  }
}

AI actions

Documentation

Purpose

Model a Jenkins declarative pipeline as JSON so it can be generated, linted, or transformed before emitting a Jenkinsfile.

When to use

Programmatically authoring Jenkins pipelines, or storing pipeline shape in a database/UI before rendering Groovy.

Required fields

  • agent — where the pipeline runs
  • stages — the ordered list of build stages
  • name + steps — each stage’s label and commands

Optional fields

  • parameters — build-time inputs
  • environment — variables available to steps
  • post — actions on success/failure/always

Best practices

  • Keep stages small and named for readability in the UI.
  • Fail fast — put quick checks (lint) before slow ones (integration).
  • Store credentials in Jenkins Credentials, referenced by ID.

Security considerations

  • Never inline secrets; use the credentials() binding by ID.
  • Restrict which agents/nodes a sensitive pipeline can run on.
  • Avoid interpolating untrusted input into shell steps.