Effortlessly Automate Your Builds and Deployments: A Complete Guide to Jenkins Pipelines for Multiple Programming Languages
Sure, here are some examples of Jenkins pipelines for different programming languages:
- Java pipeline:
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'mvn clean install'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
stage('Deploy') {
steps {
sh 'scp target/my-app.war user@prod-server:/opt/tomcat/webapps'
}
}
}
}
- Python pipeline:
pipeline {
agent any
stages {
stage('Install') {
steps {
sh 'pip install -r requirements.txt'
}
}
stage('Test') {
steps {
sh 'pytest'
}
}
stage('Deploy') {
steps {
sh 'rsync -avz . user@prod-server:/opt/app'
}
}
}
}
- Node.js pipeline:
pipeline {
agent any
stages {
stage('Install') {
steps {
sh 'npm install'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
stage('Build') {
steps {
sh 'npm run build'
}
}
stage('Deploy') {
steps {
sh 'rsync -avz . user@prod-server:/opt/app'
}
}
}
}
- Ruby pipeline:
pipeline {
agent any
stages {
stage('Install') {
steps {
sh 'bundle install'
}
}
stage('Test') {
steps {
sh 'rspec'
}
}
stage('Deploy') {
steps {
sh 'cap production deploy'
}
}
}
}