Jenkins remains widely used for self-hosted CI/CD. Put the pipeline in a Jenkinsfile in the repository so it is versioned and reviewed like code.
pipeline {
agent any
options { timeout(time: 20, unit: 'MINUTES') }
stages {
stage('Build') {
steps { sh 'npm ci' }
}
stage('Test') {
steps { sh 'npm test' }
}
stage('Package') {
when { branch 'main' }
steps { sh 'docker build -t registry.example.com/app:${BUILD_NUMBER} .' }
}
}
post { failure { echo 'Build failed' } }
}
Tips:
- Run Jenkins on Java 11 (Java 17 is supported from the 2.346 LTS line).
- Use Credentials for secrets, never plain text in the file.
- Use agents or containers for builds instead of running work on the controller.
- Keep plugins few and updated, and back up
JENKINS_HOME.