Back to Skills

jenkins-pipeline

aj-geddes
Updated Today
20 views
7
7
View on GitHub
Metaautomationdesign

About

This Claude Skill helps developers build Jenkins pipelines using both declarative and scripted approaches. It enables creating multi-stage CI/CD workflows with agents, parameters, and plugin integrations. Use it for implementing enterprise-grade deployment automation and complex multi-branch pipeline configurations.

Documentation

Jenkins Pipeline

Overview

Create enterprise-grade Jenkins pipelines using declarative and scripted approaches to automate building, testing, and deploying with advanced control flow.

When to Use

  • Enterprise CI/CD infrastructure
  • Complex multi-stage builds
  • On-premise deployment automation
  • Parameterized builds

Implementation Examples

1. Declarative Pipeline (Jenkinsfile)

pipeline {
    agent { label 'linux-docker' }
    environment {
        REGISTRY = 'docker.io'
        IMAGE_NAME = 'myapp'
    }
    parameters {
        string(name: 'DEPLOY_ENV', defaultValue: 'staging')
    }
    stages {
        stage('Checkout') { steps { checkout scm } }
        stage('Install') { steps { sh 'npm ci' } }
        stage('Lint') { steps { sh 'npm run lint' } }
        stage('Test') {
            steps {
                sh 'npm run test:coverage'
                junit 'test-results.xml'
            }
        }
        stage('Build') {
            steps {
                sh 'npm run build'
                archiveArtifacts artifacts: 'dist/**/*'
            }
        }
        stage('Deploy') {
            when { branch 'main' }
            steps {
                sh 'kubectl set image deployment/app app=${REGISTRY}/${IMAGE_NAME}:latest'
            }
        }
    }
    post {
        always { cleanWs() }
        failure { echo 'Pipeline failed!' }
    }
}

2. Scripted Pipeline (Groovy)

// Jenkinsfile - Scripted Pipeline

node('linux-docker') {
    def imageTag = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
    def registry = 'docker.io'

    try {
        stage('Checkout') { checkout scm }
        stage('Install') { sh 'npm ci' }
        stage('Test') { sh 'npm test' }
        stage('Build') { sh 'npm run build' }

        currentBuild.result = 'SUCCESS'
    } catch (Exception e) {
        currentBuild.result = 'FAILURE'
        error("Build failed: ${e.message}")
    }
}

3. Multi-Branch Pipeline

pipeline {
    agent any
    stages {
        stage('Build') { steps { sh 'npm run build' } }
        stage('Test') { steps { sh 'npm test' } }
        stage('Deploy') {
            when { branch 'main' }
            steps { sh 'npm run deploy:prod' }
        }
    }
}

4. Parameterized Pipeline

pipeline {
    agent any
    parameters {
        string(name: 'VERSION', defaultValue: '1.0.0', description: 'Version to release')
        choice(name: 'ENV', choices: ['staging', 'prod'], description: 'Deployment environment')
    }
    stages {
        stage('Build') { steps { sh 'npm run build' } }
        stage('Test') { steps { sh 'npm test' } }
        stage('Deploy') {
            steps { sh "npm run deploy:${params.ENV}" }
        }
    }
}

5. Pipeline with Credentials

pipeline {
    agent any
    environment {
        DOCKER_CREDS = credentials('docker-hub')
    }
    stages {
        stage('Build & Push') {
            steps {
                sh '''
                    echo $DOCKER_CREDS_PSW | docker login -u $DOCKER_CREDS_USR --password-stdin
                    docker build -t myapp:latest .
                    docker push myapp:latest
                '''
            }
        }
    }
}

Best Practices

✅ DO

  • Use declarative pipelines for clarity
  • Use credentials plugin for secrets
  • Archive artifacts and reports
  • Implement approval gates for production
  • Keep pipelines modular and reusable

❌ DON'T

  • Store credentials in pipeline code
  • Ignore pipeline errors
  • Skip test coverage reporting
  • Use deprecated plugins

Resources

Quick Install

/plugin add https://github.com/aj-geddes/useful-ai-prompts/tree/main/jenkins-pipeline

Copy and paste this command in Claude Code to install this skill

GitHub 仓库

aj-geddes/useful-ai-prompts
Path: skills/jenkins-pipeline

Related Skills

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill

Algorithmic Art Generation

Meta

This skill helps developers create algorithmic art using p5.js, focusing on generative art, computational aesthetics, and interactive visualizations. It automatically activates for topics like "generative art" or "p5.js visualization" and guides you through creating unique algorithms with features like seeded randomness, flow fields, and particle systems. Use it when you need to build reproducible, code-driven artistic patterns.

View skill

webapp-testing

Testing

This Claude Skill provides a Playwright-based toolkit for testing local web applications through Python scripts. It enables frontend verification, UI debugging, screenshot capture, and log viewing while managing server lifecycles. Use it for browser automation tasks but run scripts directly rather than reading their source code to avoid context pollution.

View skill