PluginBench
Skill
Pass
Audit score 90

jenkins-pipeline

aj-geddes/useful-ai-prompts

Build enterprise Jenkins pipelines with declarative and scripted syntax for CI/CD automation.

What is jenkins-pipeline?

This skill enables you to create and configure Jenkins pipelines using both declarative and scripted approaches. Use it to automate building, testing, and deploying applications with multi-stage workflows, parameters, credentials, and deployment gates.

  • Define declarative and scripted pipelines with stages and agents
  • Configure environment variables, parameters, and credentials securely
  • Implement multi-branch pipelines for complex workflows
  • Archive artifacts and generate test reports
  • Set up approval gates and conditional deployment logic
  • Integrate with Docker, plugins, and on-premise infrastructure

How to install jenkins-pipeline

npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill jenkins-pipeline
Prerequisites
  • Jenkins server installed and configured
  • Jenkins Pipeline plugin enabled
  • Access to Jenkins UI or Jenkinsfile repository
  • Docker or build agent labels configured (optional)
Claude Code
Cursor
Windsurf
Cline

How to use jenkins-pipeline

  1. 1.Define a Jenkinsfile in your repository root using declarative or scripted syntax
  2. 2.Configure agent labels to specify where pipeline stages run
  3. 3.Add environment variables and parameters for build configuration
  4. 4.Implement stages for checkout, build, test, and deploy steps
  5. 5.Use credentials plugin to securely manage secrets and API tokens
  6. 6.Archive artifacts and test reports for visibility
  7. 7.Add approval gates or conditions for production deployments
  8. 8.Trigger pipeline from SCM webhooks or manual execution

Use cases

Good for
  • Enterprise CI/CD pipelines for multi-stage builds and deployments
  • Parameterized builds with environment-specific configurations
  • Multi-branch pipelines for feature branches and release management
  • Automated testing and artifact archival in deployment workflows
  • On-premise deployment automation with approval gates
Who it's for
  • DevOps engineers
  • CI/CD pipeline architects
  • Enterprise software teams
  • Infrastructure automation specialists

jenkins-pipeline FAQ

What's the difference between declarative and scripted pipelines?

Declarative pipelines use a structured, predefined syntax with clear sections (agent, stages, post) and are easier to read and maintain. Scripted pipelines use Groovy code for more flexibility and complex control flow but require more expertise.

How do I securely store credentials in Jenkins pipelines?

Use the Jenkins Credentials plugin to store secrets, then reference them in your pipeline using the credentials() function or withCredentials() block. Never hardcode credentials in Jenkinsfile.

Can I run different stages on different agents?

Yes. You can specify agent labels at the pipeline level or override them per stage using agent { label 'agent-name' } to run stages on different machines or Docker containers.

How do I archive test results and artifacts?

Use the junit step to parse test reports and archiveArtifacts to save build outputs. Both are typically placed in the post section or relevant stage steps.

What are approval gates and how do I implement them?

Approval gates pause pipeline execution and require manual approval before proceeding. Implement them using the input step in a stage to block deployment until an authorized user approves.

Full instructions (SKILL.md)

Source of truth, from aj-geddes/useful-ai-prompts.


name: jenkins-pipeline description: > Build Jenkins declarative and scripted pipelines with stages, agents, parameters, and plugins. Implement multi-branch pipelines and deployment automation.

Jenkins Pipeline

Table of Contents

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

Quick Start

Minimal working example:

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/**/*'
            }
        }
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Declarative Pipeline (Jenkinsfile)Declarative Pipeline (Jenkinsfile)
Scripted PipelineScripted Pipeline (Groovy), Multi-Branch Pipeline, Parameterized Pipeline, Pipeline with Credentials

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