Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vadim-Zenin/f2a579ba7e09a03605101e6f7d1311a4 to your computer and use it in GitHub Desktop.
Save Vadim-Zenin/f2a579ba7e09a03605101e6f7d1311a4 to your computer and use it in GitHub Desktop.
Jenkins 2.121.2 pipeline example short
// Jenkins pipeline example short. Jenkins 2.121.2 on Ubuntu 16.04.4 LTS
// Jenkinsfile-pipeline-example-short.groovy
pipeline {
agent any
environment {
MY_DOCKER_DIR = 'docker-images'
MY_DOCKER_EXPORT_DIR = '/tmp'
MY_DOCKER_IMPORT_DIR = '/mnt/data/jenkins/jenkins-agent'
MY_DEST_SERVER = 'server-01'
}
stages {
stage('Clone repository on master') {
agent { label 'master' }
steps {
echo 'Clone repository on master'
REPLACE_ME
}
}
stage('Stop QA env') {
agent { label 'master' }
steps {
timeout(50) {
echo 'Shutdown docker containers'
REPLACE_ME
}
}
}
stage('Clone repository on agent') {
agent { label 'MY_qa_deploy' }
steps {
echo 'Clone repository on agent'
REPLACE_ME
}
}
stage('Run docker images and test') {
agent { label 'master' }
steps {
echo 'Run docker images and test'
timeout(30) {
REPLACE_ME
}
script {
REPLACE_ME
}
}
}
stage('Build docker images') {
agent { label 'master' }
steps {
echo 'Build docker images'
REPLACE_ME
}
}
stage('Export docker images') {
agent { label 'master' }
steps {
timeout(20) {
echo 'Export docker images'
REPLACE_ME
}
}
}
stage('Copy to destination server') {
agent { label 'master' }
steps {
sh 'echo "Copy to destination server env.MY_DEST_SERVER: \${MY_DEST_SERVER}"'
REPLACE_ME
}
}
stage('Import on destination server') {
agent { label 'MY_qa_deploy' }
steps {
timeout(20) {
sh 'echo "env.MY_DOCKER_IMPORT_DIR: \${MY_DOCKER_IMPORT_DIR}; env.MY_DOCKER_DIR: \${MY_DOCKER_DIR};"'
REPLACE_ME
}
}
}
stage('Start on destination server') {
agent { label 'MY_qa_deploy' }
steps {
timeout(25) {
echo 'Start on destination server'
REPLACE_ME
}
}
}
stage('Test QA from build') {
steps {
script {
REPLACE_ME
}
}
}
}
post {
always {
echo 'INFO: Post: always'
script {
mail to: 'my-build-notification-always@example.com', subject: 'jenkins bot', body: 'test always', mimeType: "text/html"
}
}
success {
echo 'INFO: Post: success'
script {
mail to: 'my-build-notification-success@example.com', subject: 'Build success', body: 'Build success', mimeType: "text/html"
}
}
failure {
echo 'INFO: Post: failure, failed'
script {
mail to: 'my-build-notification-failure@example.com', subject: 'Build failed', body: 'Build failed', mimeType: "text/html"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment