Jenkinsfile.bk 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. pipeline {
  2. agent {
  3. kubernetes {
  4. yamlFile 'deploy/KubernetesPod.yaml'
  5. retries 2
  6. }
  7. }
  8. environment {
  9. IMAGE_REPO = "zzzx9714"
  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 -t ${IMAGE_REPO}/helmbe:idcprod --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 login -u zzzx9714 -p zx999714.'
  33. sh 'docker push ${IMAGE_REPO}/helmbe:idcprod '
  34. echo "Push image success"
  35. }
  36. script {
  37. env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
  38. }
  39. }
  40. }
  41. stage('重启服务') {
  42. steps {
  43. container('kubectl') {
  44. sh 'kubectl version'
  45. }
  46. script {
  47. env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
  48. }
  49. sh 'printenv'
  50. }
  51. }
  52. }
  53. }