Jenkinsfile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. pipeline {
  2. agent {
  3. label "swarm"
  4. }
  5. environment {
  6. DOCKER_REGISTRY='dev-registry.infoclinica.ru:5000'
  7. DOCKER_IMAGE='ovpn'
  8. SERVICE_IMAGE='container_run'
  9. SERVICE_NAME='ovpn'
  10. SWARM_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/stack-deploy.git'
  11. SWARM_GIT_NAME='stack-deploy'
  12. PKI_GIT_URL='ssh://git@git.sdsys.ru:8022/iru/openvpn-pki.git'
  13. PKI_GIT_NAME='openvpn-pki'
  14. GOST_GIT_DIR='openvpn'
  15. JENKINS_MAIL='jenkins@sdsys.ru'
  16. CLUSTER_NAME='dev-iru-swarm.infoclinica.lan'
  17. }
  18. parameters {
  19. string(
  20. name: "repo",
  21. defaultValue: "prod",
  22. description: "Repository to build and/or deploy from."
  23. )
  24. string(
  25. name: "mailto",
  26. defaultValue: "tomishinets.v@sdsys.ru",
  27. description: "Email which has to be notified."
  28. )
  29. }
  30. stages {
  31. stage("Pull PKI repo") {
  32. steps {
  33. withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
  34. sh '''GIT_SSH_COMMAND='ssh -i ${GIT_SSH_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' \
  35. git clone ${PKI_GIT_URL}
  36. '''
  37. }
  38. sh '''cp ${WORKSPACE}/openvpn-pki/open/easy-rsa/keys/ca.crt \
  39. ${WORKSPACE}/openvpn-pki/open/easy-rsa/keys/server.crt \
  40. ${WORKSPACE}/openvpn-pki/open/easy-rsa/keys/server.key \
  41. ${WORKSPACE}/openvpn-pki/open/easy-rsa/keys/sds-client.crt \
  42. ${WORKSPACE}/openvpn-pki/open/easy-rsa/keys/sds-client.key \
  43. ${WORKSPACE}/openvpn-pki/open/easy-rsa/keys/ta.key \
  44. ${WORKSPACE}/openvpn-pki/open/easy-rsa/keys/stonevpn.crl \
  45. ${WORKSPACE}/openvpn-pki/open/easy-rsa/keys/dh2048.pem \
  46. ${WORKSPACE}/openvpn/keys
  47. ls -al ${WORKSPACE}/openvpn/keys/
  48. '''
  49. }
  50. }
  51. stage("Build") {
  52. steps {
  53. echo "Building ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER}."
  54. sh "docker build --no-cache -t ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${BUILD_NUMBER} ."
  55. }
  56. }
  57. }
  58. post {
  59. always {
  60. deleteDir()
  61. }
  62. }
  63. }