Jenkinsfile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. pipeline {
  2. agent {
  3. label "swarm"
  4. }
  5. environment {
  6. git_url=""
  7. docker_registry='dev-registry.infoclinica.ru:5000'
  8. docker_image='node'
  9. }
  10. parameters {
  11. string(
  12. name: "build",
  13. defaultValue: "true",
  14. description: "To build image set built to 'true'. To not build, set parameter to anything else - 'false'."
  15. )
  16. string(
  17. name: "repo",
  18. defaultValue: "prod",
  19. description: "Repository to build and/or deploy from."
  20. )
  21. string(
  22. name: "service_update",
  23. defaultValue: "",
  24. description: "Services to update - i.e. info_node or/and info_node-api. Lave empty to not update services."
  25. )
  26. }
  27. stages {
  28. stage("Build") {
  29. when { expression { build == "true" } }
  30. steps {
  31. echo "Building with repo $repo"
  32. sh "echo docker build -t ${docker_registry}/${docker_image}:${repo}-${BUILD_NUMBER} ${WORKSPACE}"
  33. }
  34. }
  35. stage("Update") {
  36. when { expression { service_update != "" } }
  37. steps {
  38. echo "Updating .$service_update."
  39. script {
  40. for (String item : service_update.split()) {
  41. echo "Updating $item"
  42. }
  43. }
  44. sh 'ls'
  45. }
  46. }
  47. }
  48. post {
  49. always {
  50. echo "It's always good to be here."
  51. }
  52. changed {
  53. echo "Something changed..."
  54. }
  55. failure {
  56. echo "Oh, snap. It's failed again"
  57. }
  58. success {
  59. echo "Fine !!! It's SUCCESS !!!"
  60. }
  61. unstable {
  62. echo "Unstable ...."
  63. }
  64. aborted {
  65. echo "Hmmm... It's aborted"
  66. }
  67. }
  68. }