agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/devops/jenkins/SKILL.md

jenkins

Skill15 starsChanged 42 days agoMITView on GitHub

Expert Jenkins automation server assistance covering declarative Jenkinsfiles, shared libraries, multi-branch pipelines, and plugins. Use when managing enterprise CI/CD build automation.

  • Reads credentials

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use isolated container execution in declarative Jenkinsfile:

    line 162
  2. Very specific:

    Always use Declarative Pipeline syntax (pipeline {}) rather than legacy Scripted Pipeline syntax.

    line 192
  3. Very specific:

    Run builds exclusively on ephemeral agents (Kubernetes Pods or Docker containers).

    line 193
  4. Distinctive:

    Run long-running builds directly on the Jenkins controller node.

    line 201

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Jenkins

Jenkins is an extensible, open-source automation server supporting pipeline-as-code (Jenkinsfile), distributed agent execution on Kubernetes, and enterprise CI/CD workflows.

When to Use

  • Self-Hosted Enterprise CI/CD Orchestration: Highly customizable build pipelines behind corporate firewalls.
  • Declarative Jenkinsfile Pipelines: Version-controlled pipelines with stages, environments, and automated rollback gates.
  • Distributed Agent Fleets: Running parallel builds across dynamic Kubernetes pods, Docker containers, and VMs.
  • Legacy Migration & Complex Tooling Integrations: Leveraging thousands of established community plugins.

Quick Start

// Jenkinsfile
pipeline {
    agent { docker { image 'node:20' } }
    stages {
        stage('Build') {
            steps {
                sh 'npm ci'
                sh 'npm run build'
            }
        }
    }
}

Core Concepts

Declarative Jenkinsfile with Docker Agents & Parallel Stages

Modern pipeline structure running in parallel stages:

// Jenkinsfile
pipeline {
    agent {
        docker {
            image 'node:22-alpine'
            args '-u root:root'
        }
    }
    options {
        timeout(time: 1, unit: 'HOURS')
        disableConcurrentBuilds()
        ansiColor('xterm')
    }
    environment {
        CI = 'true'
        NPM_CONFIG_CACHE = "${WORKSPACE}/.npm"
    }
    stages {
        stage('Install') {
            steps {
                sh 'npm ci'
            }
        }
        stage('Quality Gates') {
            parallel {
                stage('Lint & Typecheck') {
                    steps {
                        sh 'npm run lint'
                        sh 'npm run typecheck'
                    }
                }
                stage('Unit Tests') {
                    steps {
                        sh 'npm test -- --coverage'
                    }
                    post {
                        always {
                            junit 'junit.xml'
                        }
                    }
                }
            }
        }
        stage('Deploy to Staging') {
            when {
                branch 'main'
            }
            steps {
                withCredentials([string(credentialsId: 'STAGING_API_KEY', variable: 'API_KEY')]) {
                    sh 'npm run deploy:staging'
                }
            }
        }
    }
    post {
        failure {
            slackSend(channel: '#ci-alerts', color: 'danger', message: "Pipeline Failed: ${env.JOB_NAME} #${env.BUILD_NUMBER}")
        }
    }
}

Kubernetes Dynamic Cloud Agents

Spawning ephemeral build pods dynamically in Kubernetes:

pipeline {
    agent {
        kubernetes {
            yaml '''
apiVersion: v1
kind: Pod
metadata:
  labels:
    some-label: build-agent
spec:
  containers:
  - name: maven
    image: maven:3.9-eclipse-temurin-21
    command: ['cat']
    tty: true
'''
        }
    }
    stages {
        stage('Build') {
            steps {
                container('maven') {
                    sh 'mvn clean package -DskipTests'
                }
            }
        }
    }
}

Jenkins Configuration as Code (JCasC)

Managing Jenkins master controller configuration declaratively:

# jenkins.yaml
jenkins:
  systemMessage: "Enterprise Production CI/CD Controller - Managed via JCasC"
  numExecutors: 0 # Master runs zero builds; all work on agents
  mode: EXCLUSIVE
security:
  queueItemAuthenticator:
    authenticators:
      - global:
          strategy: triggeringUsersAuthorizationStrategy

Common Patterns

Declarative Pipeline with Docker Agent and Post-Build Notifications

Problem: Build environment drift across physical Jenkins worker nodes.

Solution: Use isolated container execution in declarative Jenkinsfile:

pipeline {
    agent {
        docker {
            image 'node:20-alpine'
            args '-u root'
        }
    }
    stages {
        stage('Install & Test') {
            steps {
                sh 'npm ci'
                sh 'npm test'
            }
        }
    }
    post {
        failure {
            slackSend channel: '#ci-alerts', message: "Job ${env.JOB_NAME} failed!"
        }
    }
}

Best Practices

Do:

  • Always use Declarative Pipeline syntax (pipeline {}) rather than legacy Scripted Pipeline syntax.
  • Run builds exclusively on ephemeral agents (Kubernetes Pods or Docker containers); set numExecutors: 0 on the master controller.
  • Store all secrets in Jenkins Credential Store and inject them using withCredentials().
  • Manage master controller configuration using Jenkins Configuration as Code (JCasC).

Don't:

  • Install unverified third-party plugins; audit and minimize plugin counts to prevent security vulnerabilities.
  • Hardcode sensitive API tokens or passwords directly inside Jenkinsfile.
  • Run long-running builds directly on the Jenkins controller node.

Troubleshooting

ErrorCauseSolution
java.lang.OutOfMemoryError: Java heap spaceMaster/controller JVM heap limit exhausted by build history.Increase -Xmx parameter in Jenkins JVM options and discard old builds.
Scripts not permitted to use methodGroovy script attempting restricted method call under sandbox.Navigate to Manage Jenkins > In-process Script Approval and approve method.
Cannot connect to Docker daemon in agentDocker socket not mounted into the executor container.Mount socket: args '-v /var/run/docker.sock:/var/run/docker.sock'.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.