Created
July 30, 2018 14:05
-
-
Save Vadim-Zenin/f2a579ba7e09a03605101e6f7d1311a4 to your computer and use it in GitHub Desktop.
Jenkins 2.121.2 pipeline example short
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: '[email protected]', subject: 'jenkins bot', body: 'test always', mimeType: "text/html" | |
} | |
} | |
success { | |
echo 'INFO: Post: success' | |
script { | |
mail to: '[email protected]', subject: 'Build success', body: 'Build success', mimeType: "text/html" | |
} | |
} | |
failure { | |
echo 'INFO: Post: failure, failed' | |
script { | |
mail to: '[email protected]', 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