12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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: "<b>ATTENTION!!!</b> <br><br><br> Jenkins job failed. <br>Project Name: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br>Build Tag: <b>${REV_NUMBER}-${env.BUILD_NUMBER}</b><br>URL Build:${RUN_DISPLAY_URL}"
- }
- success {
- mail charset: 'UTF-8',
- subject: "Jenkins Analis Server docker image build SUCCESS",
- mimeType: 'text/html',
- to: "${mailto}",
- body: "<b>Congradulations!!!</b> <br><br><br> Jenkins job <b>succefully</b> finished.\n\n <br>Project Name: ${env.JOB_NAME} <br>\nBuild Number: ${env.BUILD_NUMBER} <br>\nBuild Tag: <b>${REV_NUMBER}-${env.BUILD_NUMBER}</b><br>\nURL Build: ${RUN_DISPLAY_URL}"
- }
- }
- }
|