Deploying Apps
After building and testing, you need to deploy your application. Jenkins can deploy to various targets: SSH servers, cloud platforms, Kubernetes, or container registries.
Deploying via SSH (SCP/SSH)
Install the "Publish Over SSH" plugin. Configure SSH servers in "Manage Jenkins" → "Configure System". Then use the
sshPublisher step.stage('Deploy') {
steps {
sshPublisher(publishers: [
sshPublisherDesc(configName: 'prod-server', transfers: [
sshTransfer(sourceFiles: 'target/*.war', remoteDirectory: '/deploy', execCommand: 'sudo systemctl restart tomcat')
])
])
}
}Deploying to Kubernetes
Use the Kubernetes plugin or the
kubectl command inside a container.stage('Deploy to K8s') {
steps {
withKubeConfig([credentialsId: 'kubeconfig']) {
sh 'kubectl apply -f k8s/deployment.yaml'
}
}
}Deploying to Docker Registry
Push a Docker image to a registry, then pull and run on a target server.
docker.withRegistry('https://registry.hub.docker.com', 'docker-cred') {
docker.image('myapp:latest').push()
}Using Cloud Providers (AWS, Azure, GCP)
Install cloud‑specific plugins (e.g., AWS Steps, Azure Pipeline). They provide steps to interact with S3, EC2, or Azure App Services.
Rollback Strategies
For safe deployments, implement blue‑green or canary. Jenkins can trigger rollback if health checks fail.
Two Minute Drill
- Use Publish Over SSH plugin for deployment to remote servers.
- For Kubernetes, use
kubectlwith kubeconfig credentials. - Push Docker images to registry, then deploy.
- Always include rollback or health check steps.
Need more clarification?
Drop us an email at career@quipoinfotech.com
