How to set up a Jenkins pipeline?

· Category: DevOps & CI/CD

Short answer

A Jenkins pipeline is set up by creating a new pipeline job and pointing it to a source control repository containing a Jenkinsfile.

Steps

  1. Click New Item and select Pipeline.
  2. Configure the repository URL and credentials.
  3. Set the script path to Jenkinsfile.
  4. Save and run the pipeline.

Example

pipeline {
    agent any
    environment {
        NODE_ENV = 'production'
    }
    stages {
        stage('Build') {
            steps {
                sh 'npm ci'
                sh 'npm run build'
            }
        }
    }
}

Tips

  • Use Multibranch Pipelines for automatic branch scanning.
  • Set webhook triggers for fast feedback.
  • Archive artifacts with archiveArtifacts.

Common issues

  • Repository credentials must be configured correctly.
  • The Jenkinsfile path is case-sensitive.
  • Webhooks may fail if Jenkins is behind a firewall.