
Jenkins Pipeline
Scaffold declarative or scripted Jenkinsfiles so your agent can wire checkout, test, build, and conditional deploy stages without guessing Groovy syntax.
Overview
jenkins-pipeline is an agent skill for the Ship phase that supplies declarative and scripted Jenkinsfile templates for checkout-through-deploy Node CI/CD.
Install
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill jenkins-pipelineWhat is this skill?
- Declarative pipeline template with agent label, environment block, string parameters, and multi-stage flow
- Stages for checkout, npm ci, lint, coverage tests with JUnit publishing, dist archiveArtifacts, and main-branch kubectl
- Scripted pipeline variant with git short-SHA tagging and try/catch-style stage orchestration on docker agents
- post always cleanWs and failure notification hooks for workspace hygiene
- Two pipeline styles documented: declarative and scripted Jenkinsfile examples
Adoption & trust: 904 installs on skills.sh; 250 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need a Jenkins pipeline but Groovy stage wiring, artifacts, and branch-gated deploy steps are easy to get wrong in ad-hoc chat.
Who is it for?
Indie teams already on Jenkins who want a consistent npm test-and-deploy pipeline pattern generated or reviewed by an agent.
Skip if: Builders on GitHub Actions, GitLab CI, or Fly/Vercel-only deploys who will not maintain a Jenkins controller and agents.
When should I use this skill?
You are authoring or refactoring a Jenkinsfile for checkout, test, build, and deploy on a Linux docker agent.
What do I get? / Deliverables
You get runnable Jenkinsfile skeletons with ordered stages, test reporting hooks, artifact archival, and main-branch deploy you can tailor to your registry and cluster.
- Jenkinsfile (declarative or scripted)
- Stage definitions for lint, test, build, and optional deploy
Recommended Skills
Journey fit
Continuous integration and deploy pipelines are defined and hardened in the Ship phase before production releases. Launch subphase covers release automation—Jenkinsfiles are the canonical artifact for getting builds to staging or production.
How it compares
Use for Groovy Jenkinsfile patterns instead of generic “write me a CI yaml” without Jenkins-specific agent, post, and junit steps.
Common Questions / FAQ
Who is jenkins-pipeline for?
Solo and small-team builders shipping web or API projects through self-hosted Jenkins who want agent-assisted Jenkinsfile authoring.
When should I use jenkins-pipeline?
During Ship when you are creating or updating release automation—for example adding lint and coverage gates before kubectl deploy on main, or converting an informal shell script into a declarative pipeline.
Is jenkins-pipeline safe to install?
It is documentation and template Groovy only; review the Security Audits panel on this Prism page before trusting the package source, and never paste deploy credentials into prompts.
SKILL.md
READMESKILL.md - Jenkins Pipeline
# Declarative Pipeline (Jenkinsfile) ## Declarative Pipeline (Jenkinsfile) ```groovy 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!' } } } ``` # Scripted Pipeline ## Scripted Pipeline (Groovy) ```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}") } } ``` ## Multi-Branch Pipeline ```groovy 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' } } } } ``` ## Parameterized Pipeline ```groovy 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}" } } } } ``` ## Pipeline with Credentials ```groovy 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 ''' } } } } ``` #!/bin/bash # validate-pipeline.sh - Validate CI/CD pipeline configuration # Usage: ./validate-pipeline.sh <pipeline_file> set -euo pipefail PIPELINE_FILE="${{1:?Usage: $0 <pipeline_file>}}" echo "Validating pipeline: $PIPELINE_FILE" # TODO: Add pipeline validation # - Check YAML/Groovy syntax # - Verify stage dependencies # - Check for required stages (build, test, deploy) # - Validate environment variable references # - Check for security best practices echo "Pipeline validation complete." --- 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](#overview) - [When to Use](#when-to-use) - [Quick Start](#quick-start) - [Reference Guides](#reference-guides) - [Best Practices](#best-practices) ## Overview Create enterprise-grade Jenkins pipelines using declarative and scripted approaches to automate building, testing, an