Skip to main content
Jenkins beginner Lesson 1 of 4

Jenkins CI: Pipeline Basics

Learn what Jenkins is and how to use declarative pipelines: stages, agents, steps, and basic CI patterns.

Jenkins is a CI server that automates build/test/release workflows. Even if you use it less today, understanding Jenkins pipeline concepts helps you reason about CI systems generally.

Theory first: pipelines as executable delivery design

A CI pipeline is an executable model of your delivery process. Each stage encodes a quality boundary (build, test, security, deploy), and failures represent policy violations—not just broken scripts.

This framing keeps Jenkins practical: you are designing trustworthy flow control for change, where feedback speed and reproducibility matter as much as successful builds.

Learning outcomes

By the end you can:

  • understand Jenkins pipeline stages
  • run commands in steps
  • use agents/nodes to control execution environment

1) Pipeline overview

A Jenkins pipeline is a script describing what to run and when. Today, declarative pipelines are most common.

2) Minimal declarative pipeline

Jenkinsfile:

pipeline {
  agent any

  stages {
    stage('Checkout') {
      steps {
        checkout scm
      }
    }

    stage('Install') {
      steps {
        sh 'npm ci'
      }
    }

    stage('Test') {
      steps {
        sh 'npm test'
      }
    }
  }
}

3) Common stage patterns

Lint + test

stage('Lint') {
  steps { sh 'npm run lint' }
}

stage('Test') {
  steps { sh 'npm test' }
}

Build + archive

stage('Build') {
  steps {
    sh 'npm run build'
    archiveArtifacts artifacts: 'dist/**', fingerprint: true
  }
}

4) Choosing an execution environment

Declarative pipeline:

agent {
  docker {
    image 'node:20-alpine'
    args '-u node'
  }
}

Or run on specific labeled agents:

agent { label 'linux-x64' }

5) Secrets and credentials (conceptual)

Jenkins uses a credentials store so you don’t hardcode secrets in the Jenkinsfile. Common usage pattern is withCredentials.

Example (concept):

withCredentials([string(credentialsId: 'API_TOKEN', variable: 'API_TOKEN')]) {
  sh 'curl -H "Authorization: Bearer $API_TOKEN" https://api.example.com'
}

Next steps

Next tutorials:

  • Jenkins credentials + artifacts
  • Multi-stage releases
  • Pair with monitoring: alerts on pipeline failures

Frequently Asked Questions

Is Jenkins obsolete now that GitHub Actions exists?
No—Jenkins is still common in enterprises with existing infrastructure, custom agents, and plugin ecosystems. The core CI/pipeline concepts transfer.
What’s the difference between an agent and a node?
In Jenkins Pipeline, an agent (declarative) chooses where stages run. Under the hood it maps to nodes/executors.