Best Languages for Flexible CI/CD Pipelines

Which languages fit each CI/CD layer: YAML for definitions, Groovy for Jenkins, Bash in steps, Python and Go for logic, and code-first tools like Dagger.

Aug 21, 2025 - 10:23
Nov 9, 2026 - 05:32
 0  75
Best Languages for Flexible CI/CD Pipelines

Most CI/CD pipelines are written in YAML, with Bash for the commands inside each step. Jenkins uses a Groovy-based DSL. When pipeline logic grows beyond what YAML expresses cleanly, teams move it into Python or Go scripts, or into code-first tools such as Dagger, which offers SDKs for Go, Python, TypeScript and other languages.

Each language fits a different layer of the pipeline, so this post sorts the options by job: describing the pipeline, running commands, holding complex logic, and sharing reusable building blocks. For worked examples of complete pipelines, see our 18 CI/CD pipeline examples from big tech companies.

Key takeaways

  • YAML is the default definition language for GitHub Actions, GitLab CI/CD, Azure Pipelines, Bitbucket Pipelines and Tekton. Learn it first.
  • Jenkins Pipeline is built on Groovy. Declarative syntax is the opinionated form; Scripted syntax is a general-purpose Groovy DSL.
  • Bash runs inside almost every step. Keep it short and strict (set -euo pipefail).
  • Move branching logic, API calls and data handling into Python or Go scripts that you can test locally.
  • Code-first engines such as Dagger let you write the pipeline itself as a program and run it the same way on a laptop and in CI.
  • Flexibility comes mostly from reuse features (GitHub reusable workflows, GitLab CI/CD components, Jenkins shared libraries), not from picking a fancier language.

The four layers of a pipeline

LayerWhat it doesCommon languages
DefinitionDeclares stages, jobs, triggers, runners and dependenciesYAML; Groovy DSL for Jenkins
Step commandsBuilds, tests, packages, deploysBash, PowerShell on Windows runners
Logic and glueDecides what to build, calls APIs, parses reports, generates configPython, Go, JavaScript/TypeScript
Reusable modulesShared steps, templates, actions, librariesYAML templates, Groovy shared libraries, JavaScript or container actions, Dagger modules

Picking a language for each layer, rather than one language for everything, is what keeps pipelines readable as they grow.

YAML: the definition language almost everyone uses

YAML is a data format, not a programming language. That is its strength: a reviewer can read a workflow file and see the stages without running anything. Each CI system adds its own keywords on top.

# .github/workflows/ci.yml
name: ci
on:
  push:
    branches: [main]
  pull_request:
jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.11", "3.12"]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - run: pip install -r requirements.txt
      - run: pytest -q

Where YAML gets you flexibility

  • Matrices run the same job across versions or platforms.
  • Conditions (if: in GitHub Actions, rules: in GitLab) control when jobs run.
  • Reuse: GitHub reusable workflows and composite actions; GitLab include, extends and CI/CD components.

GitLab CI/CD components are a good example of reuse without leaving YAML. A component declares inputs in a spec section and is pulled in by version:

# templates/test.yml in a component project
spec:
  inputs:
    stage:
      default: test
---
unit-test:
  stage: $[[ inputs.stage ]]
  script: make test
# .gitlab-ci.yml in a consuming project
include:
  - component: $CI_SERVER_FQDN/my-org/ci-components/[email protected]
    inputs:
      stage: build

Published components can be listed in the GitLab CI/CD Catalog. See 15 GitLab CI/CD pipeline examples with YAML for more patterns.

Where YAML hurts

YAML has no real functions, loops or types. Long expressions inside ${{ }} or rule blocks become hard to test, and indentation mistakes can change meaning without an error. When you notice nested conditions and copy-pasted jobs, move logic out of YAML.

Groovy: the Jenkins language

The Jenkins Pipeline syntax docs state that Groovy was chosen as the foundation when Pipeline was created. There are two forms:

  • Declarative: a structured pipeline { } block with stages, agents and post actions. Easier to read and validate.
  • Scripted: an imperative Groovy DSL with very few limits.
pipeline {
  agent any
  stages {
    stage('Build') {
      steps { sh './gradlew build' }
    }
    stage('Deploy') {
      when { branch 'main' }
      steps {
        script {
          def envs = ['staging', 'prod']
          for (e in envs) {
            sh "./deploy.sh ${e}"
          }
        }
      }
    }
  }
}

The script step lets you drop Scripted code into a Declarative pipeline. Jenkins describes it as an escape hatch and recommends moving large or complex script blocks into Shared Libraries. That advice applies to every CI system: keep the definition file thin. Our Jenkins pipeline interview questions and 15 Jenkins pipeline templates cover Jenkinsfile structure in more depth.

Bash: the language inside the steps

Whatever the definition language, most steps end up running shell commands. Bash is everywhere on Linux runners and is the most direct way to call build tools. Use it for short sequences and keep it strict:

#!/usr/bin/env bash
set -euo pipefail

IMAGE="registry.example.com/app:${GIT_SHA}"
docker build -t "$IMAGE" .
docker push "$IMAGE"
  • set -e stops on the first failing command; -u fails on unset variables; -o pipefail catches failures inside pipes.
  • Quote variables to avoid word splitting.
  • Run shellcheck on scripts in the pipeline itself.
  • Once a script passes roughly a screen of logic, or starts parsing JSON with text tools, rewrite it in Python or Go.

Python: logic, glue and reporting

Python is the usual next step when Bash gets messy. It is installed on most runner images, reads JSON and YAML natively, and has client libraries for cloud providers and most DevOps tools. Typical jobs:

  • Working out which services changed in a monorepo and building only those.
  • Calling the GitHub, GitLab or cloud APIs to create releases or check deployment status.
  • Parsing test or security scan reports and failing the build on rules you define.
  • Generating Kubernetes manifests or pipeline config from a template.
#!/usr/bin/env python3
"""Fail the build if any critical findings appear in a JSON scan report."""
import json
import sys

with open(sys.argv[1]) as f:
    report = json.load(f)

critical = [r for r in report.get("results", []) if r.get("severity") == "CRITICAL"]
for item in critical:
    print(f"CRITICAL: {item.get('id')} in {item.get('target')}")
sys.exit(1 if critical else 0)

Because this is a normal script, you can unit test it and run it on a laptop. That is the main gain over logic embedded in YAML.

Go: fast, single-binary pipeline tools

Go compiles to a static binary, which makes it easy to ship a pipeline tool into any runner or container without installing a runtime. Much of the cloud-native toolchain (Docker, Kubernetes, Terraform, Helm) is written in Go, so Go is a natural choice when your pipeline helpers talk to those systems through their own libraries. The trade-off is more code than Python for quick scripts.

Code-first pipelines: Dagger and similar engines

Code-first tools treat the pipeline itself as a program. Dagger runs pipeline steps in containers and provides native SDKs for Go, Python, TypeScript, PHP, Java, .NET, Elixir and Rust. You write functions in your language of choice, run them locally, and call the same functions from GitHub Actions, GitLab CI or Jenkins. The CI YAML shrinks to a single step that invokes the engine.

Benefits are real types, functions, tests and the same behaviour on a laptop as in CI. Costs are an extra tool to learn and run, and pipelines that are less obvious to someone who only reads the CI file. Code-first fits teams with complex builds across many repos; plain YAML fits most single-service projects.

Comparison: which language for which job

LanguageBest forStrengthsWatch out for
YAMLPipeline definitions in GitHub Actions, GitLab, Azure Pipelines, TektonReadable, reviewable, native to the platformNo real logic or tests; indentation errors
Groovy (Jenkins DSL)Jenkinsfiles and shared librariesFull programming power inside JenkinsLogic hidden in script blocks; Jenkins-specific
BashShort command sequences in stepsAvailable everywhere, direct tool callsFragile error handling, poor data parsing
PowerShellSteps on Windows runners, Azure automationObject pipeline, good Windows coverageLess common on Linux images
PythonGlue logic, API calls, report parsingReadable, rich libraries, testableDependency management on runners
GoDistributable pipeline tools and CLIsSingle binary, fast, cloud-native librariesMore code for small scripts
TypeScript/JavaScriptGitHub JavaScript actions, Dagger modulesNative action runtime on GitHubNode dependency upkeep

Design rules that make pipelines flexible

  1. Thin definition, thick scripts. Keep YAML or Jenkinsfile as a list of steps that call versioned scripts.
  2. Make every step runnable locally. If a developer cannot reproduce a step on a laptop, debugging takes far longer.
  3. Version shared pieces. Pin reusable workflows, components and libraries to tags, not to a moving branch.
  4. Parameterise with inputs. Use workflow inputs, component inputs or Jenkins parameters instead of copying jobs.
  5. Lint and test pipeline code. Run YAML linters, shellcheck, unit tests for Python helpers, and Jenkins' Declarative linter.
  6. Keep secrets out of code. Use the CI system's secret store or an external vault. Our CI/CD pipeline security practices cover this.

A learning path for beginners

  1. YAML syntax and one CI platform (GitHub Actions or GitLab CI).
  2. Bash for build and deploy commands, with strict mode and shellcheck.
  3. Python for scripts that call APIs and parse JSON.
  4. Jenkins Declarative Pipeline if your target employers use Jenkins.
  5. Go or a code-first engine once you maintain pipelines across many repositories.

If you want guided practice, our Jenkins training and GitLab CI/CD training run in our Kharadi, Pune classroom and live online. For starter templates, see 10 cloud CI/CD pipeline templates for beginners.

Frequently asked questions

Which language is used most for CI/CD pipelines?

YAML, because GitHub Actions, GitLab CI/CD, Azure Pipelines, Bitbucket Pipelines and Tekton all define pipelines in YAML. Bash usually runs the commands inside each step.

Is Jenkinsfile written in Groovy?

Yes. Jenkins Pipeline is built on Groovy. Declarative Pipeline is a structured subset, and Scripted Pipeline is a general-purpose Groovy DSL. Large script blocks are better moved into shared libraries.

Should I write pipeline logic in Python or Bash?

Use Bash for short command sequences. Switch to Python when you need branching logic, JSON parsing, API calls or tests, because Python scripts are easier to read and unit test.

Is Go a good language for CI/CD?

Go suits pipeline tools you want to ship as a single binary, especially ones that talk to Kubernetes, Docker or Terraform through their Go libraries. For quick scripts, Python is usually faster to write.

What is Dagger in CI/CD?

Dagger is a code-first engine that runs pipeline steps in containers. It provides SDKs for Go, Python, TypeScript, PHP, Java, .NET, Elixir and Rust, so you can write pipelines as code and run them the same way locally and in CI.

How do I make a YAML pipeline more reusable?

Use GitHub reusable workflows or composite actions, or GitLab include, extends and CI/CD components with inputs. Pin shared pieces to versions and move complex logic into scripts.

Do I need to learn programming to work with CI/CD?

You can start with YAML and Bash. To build flexible pipelines you will also want one general-purpose language, and Python is the most common first choice for DevOps engineers.

Can I use PowerShell in pipelines?

Yes. Windows runners and Azure Pipelines support PowerShell steps, and PowerShell also runs on Linux. It is a good fit when you automate Windows servers or Azure resources.

References

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.