Redis operator for Kubernetes with HAProxy support
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Jenkinsfile 1.4 KiB

2 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. node {
  2. checkout scm
  3. def branch = env.BRANCH_NAME
  4. def build = env.BUILD_NUMBER
  5. def image
  6. def repository = "iam21h/redis-operator"
  7. def image_name = "${repository}"
  8. def commit_hash = checkout(scm).GIT_COMMIT
  9. def git_tag = env.TAG_NAME
  10. def version
  11. stage("Read version from file") {
  12. try {
  13. version = readFile file: "VERSION"
  14. echo "Detected version: ${version}"
  15. image_name = "${repository}:${version}"
  16. } catch (Exception e) {
  17. error("Failed to read version from file")
  18. }
  19. }
  20. stage("Build Image") {
  21. try {
  22. sh "docker build -t ${image_name} ."
  23. image = docker.image(image_name)
  24. } catch (Exception e) {
  25. error("Failed to build image")
  26. }
  27. }
  28. if ( git_tag != null ) {
  29. stage("Update Helm Chart") {
  30. sh "tar -zcvf /var/www/charts.blindage.org/redis-operator-${version}.tgz -C deploy/helm_chart ."
  31. sh "cd /var/www/charts.blindage.org/ && helm repo index ."
  32. }
  33. stage("Push Image") {
  34. try {
  35. docker.withRegistry("", "dockerhub") {
  36. image.push()
  37. }
  38. } catch(Exception e) {
  39. echo "${e}"
  40. error("Failed to push image")
  41. } finally {
  42. // cleanup
  43. sh "docker rmi ${image_name} || true"
  44. }
  45. }
  46. }
  47. }