Jenkinsfile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. pipeline {
  2. agent {
  3. kubernetes {
  4. yamlFile 'deploy/KubernetesPod.yaml'
  5. retries 2
  6. }
  7. }
  8. environment {
  9. IMAGE_REPO = "registry.cn-hangzhou.aliyuncs.com/sxtest"
  10. TAB = "\n \n "
  11. BUILD_TASKS = "\n \n "
  12. }
  13. stages{
  14. stage('构建镜像') {
  15. steps {
  16. container('docker') {
  17. echo "构建 Docker 镜像阶段"
  18. sh 'echo "nameserver 114.114.114.114" >> /etc/resolv.conf'
  19. sh 'docker build --target image-idctest -t ${IMAGE_REPO}/datax-admin:${ENV_APP} --output type=docker .'
  20. echo "build success"
  21. }
  22. script {
  23. env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
  24. }
  25. }
  26. }
  27. stage('镜像推送') {
  28. steps {
  29. container('docker') {
  30. echo "Push Docker 镜像阶段"
  31. sh'docker images'
  32. sh 'docker push ${IMAGE_REPO}/datax-admin:${ENV_APP} '
  33. echo "Push image success"
  34. }
  35. script {
  36. env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
  37. }
  38. }
  39. }
  40. stage('重启服务') {
  41. steps {
  42. container('kubectl') {
  43. sh 'kubectl version'
  44. }
  45. script {
  46. env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
  47. }
  48. sh 'printenv'
  49. }
  50. }
  51. }
  52. }