Tech Interview RoomStudy guides

CI/CD

Jenkins vs GitHub Actions vs GitLab CI: how do you structure reusable pipelines?

Intermediate · 2 min read · Lesson 4 of 6 in CI/CD

Jenkins

  • Self-hosted, extremely flexible, huge plugin ecosystem; pipelines as code in a Jenkinsfile (declarative or scripted Groovy).
  • Reuse with shared libraries (versioned Groovy code imported with @Library).
  • Operational burden: controller upgrades, plugin compatibility, scaling agents (use Kubernetes agents), securing credentials.

GitHub Actions / GitLab CI

  • Hosted with the repository, YAML workflows, managed runners plus optional self-hosted runners.
  • Reuse with reusable workflows and composite actions (GitHub) or include templates and CI/CD components (GitLab).
  • Native OIDC federation to clouds: workflows get short-lived AWS/GCP credentials without stored keys.

Structuring for many services

  • A central, versioned pipeline template (shared library or reusable workflow) that every service calls with a few parameters, so security gates and standards apply consistently and can be upgraded centrally.
  • Services can extend but not bypass the required stages (enforced with branch protection and required checks).

Example

groovy
// Jenkinsfile using a shared library
@Library('platform-pipelines@v3') _
javaServicePipeline(
    serviceName: 'order-service',
    javaVersion: '21',
    deployTo: ['dev', 'staging'],
    runPerformanceTests: true
)
yaml
# GitHub Actions: calling a reusable workflow
jobs:
  pipeline:
    uses: acme/platform-workflows/.github/workflows/java-service.yml@v3
    with: { service-name: order-service, java-version: '21' }
    secrets: inherit

Follow-up questions interviewers ask

Try answering each one before you open it.

How do you handle secrets in pipelines?

Prefer no long-lived secrets: use OIDC federation from the CI system to the cloud (GitHub Actions to AWS IAM roles or GCP Workload Identity Federation). Otherwise store secrets in the CI secret store or fetch them from Vault at runtime, scope them per environment with required approvals for production, mask them in logs, and never echo them or pass them as command-line arguments. Restrict which branches and workflows can access production credentials.

When would you use self-hosted runners?

When builds need access to private networks, special hardware (GPUs, ARM), large caches or more CPU than hosted runners offer, or for cost at very high volume. Run them as ephemeral, autoscaled containers (actions-runner-controller on Kubernetes), isolated per job, and never use them for untrusted pull requests from forks, which could execute arbitrary code inside your network.