import java.text.SimpleDateFormat pipeline { agent { label "dev-winservice" } options { timeout(time: 3, unit: 'HOURS') } environment { JENKINS_MAIL='jenkins@sdsys.ru' REV_NUMBER='' } parameters { string( name: "mailto", defaultValue: "labportal@sdsys.ru", description: "Email which has to be notified." ) } stages { stage("Build docker image") { steps { // Checkout repository powershell 'svn.exe checkout svn://192.168.21.250/programs/trunk/Services/Analis/Win64 Infoclinica --username public --password "sds#7753435"' // Discover revision number script { REV_NUMBER = powershell(returnStdout: true, script: 'svn info --show-item last-changed-revision .\\Infoclinica').trim() echo "Last-Changed-Revision number is '$REV_NUMBER'" } powershell """ Set-PSDebug -Trace 1 pwd move-Item -Path .\\Infoclinica\\.svn -Destination ..\\svn docker build -t registry.infoclinica.ru:5000/lab/analis-service:${REV_NUMBER}-${BUILD_NUMBER} . move-Item -Path ..\\svn -Destination .\\Infoclinica\\.svn """ } } stage("Push to registry"){ steps { powershell """ Set-PSDebug -Trace 1 docker tag registry.infoclinica.ru:5000/lab/analis-service:${REV_NUMBER}-${BUILD_NUMBER} registry.infoclinica.ru:5000/lab/analis-service:latest docker push registry.infoclinica.ru:5000/lab/analis-service:${REV_NUMBER}-${BUILD_NUMBER} docker push registry.infoclinica.ru:5000/lab/analis-service:latest """ } } } post { failure { mail charset: 'UTF-8', subject: "Jenkins Analis Server docker image build ERROR", mimeType: 'text/html', to: "${mailto}", body: "ATTENTION!!!


Jenkins job failed.
Project Name: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
Build Tag: ${REV_NUMBER}-${env.BUILD_NUMBER}
URL Build:${RUN_DISPLAY_URL}" } success { mail charset: 'UTF-8', subject: "Jenkins Analis Server docker image build SUCCESS", mimeType: 'text/html', to: "${mailto}", body: "Congradulations!!!


Jenkins job succefully finished.\n\n
Project Name: ${env.JOB_NAME}
\nBuild Number: ${env.BUILD_NUMBER}
\nBuild Tag: ${REV_NUMBER}-${env.BUILD_NUMBER}
\nURL Build: ${RUN_DISPLAY_URL}" } } }