Jenkinsfile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. pipeline {
  2. agent any
  3. environment {
  4. BUILD_USER = ""
  5. }
  6. stages {
  7. stage('build param') {
  8. steps {
  9. wrap([$class: 'BuildUser']) {
  10. script {
  11. BUILD_USER = "${env.BUILD_USER}"
  12. }
  13. }
  14. echo '${BUILD_USER}'
  15. }
  16. }
  17. stage('build job') {
  18. steps {
  19. sh 'node -v'
  20. sh 'npm install && npm run build'
  21. sh 'tar -zcf dist.tar.gz dist/'
  22. }
  23. }
  24. stage('deploy job') {
  25. steps {
  26. <<<<<<< HEAD
  27. sshPublisher(publishers: [sshPublisherDesc(configName: 'ECS-CooleShow-47.114.1.200-dev', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'cd /mnt/datadisk/www/cooleshow/h5-colexiu && rm -rf dist/ && tar -zxf *.tar.gz && rm *.tar.gz && systemctl restart nginx', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '/mnt/datadisk/www/cooleshow/h5-colexiu', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**/*.tar.gz')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
  28. =======
  29. sshPublisher(publishers: [sshPublisherDesc(configName: 'ECS-CooleShow-47.98.131.38-pre', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'cd /mnt/datadisk/www/jenkins/cooleshow/h5-colexiu && rm -rf dist/ && tar -zxf *.tar.gz && rm *.tar.gz', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '/mnt/datadisk/www/jenkins/cooleshow/h5-colexiu', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**/*.tar.gz')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
  30. >>>>>>> online
  31. }
  32. }
  33. stage('clean job') {
  34. steps {
  35. sh 'rm dist.tar.gz'
  36. }
  37. }
  38. }
  39. post {
  40. success {
  41. dingtalk (
  42. robot: "Jenkins",
  43. type:'ACTION_CARD',
  44. atAll: false,
  45. title: "构建成功:${env.JOB_NAME}",
  46. //messageUrl: 'xxxx',
  47. text: [
  48. "### [${env.JOB_NAME}](${env.JOB_URL}) ",
  49. '---',
  50. "- 任务:[${currentBuild.displayName}](${env.BUILD_URL})",
  51. '- 状态:<font color=#00CD00 >成功</font>',
  52. "- 持续时间:${currentBuild.durationString}".split("and counting")[0],
  53. "- 执行人:${BUILD_USER}",
  54. ]
  55. )
  56. }
  57. failure{
  58. dingtalk (
  59. robot: "Jenkins",
  60. type:'ACTION_CARD',
  61. atAll: false,
  62. title: "构建失败:${env.JOB_NAME}",
  63. //messageUrl: 'xxxx',
  64. text: [
  65. "### [${env.JOB_NAME}](${env.JOB_URL}) ",
  66. '---',
  67. "- 任务:[${currentBuild.displayName}](${env.BUILD_URL})",
  68. '- 状态:<font color=#EE0000 >失败</font>',
  69. "- 持续时间:${currentBuild.durationString}".split("and counting")[0],
  70. "- 执行人:${BUILD_USER}",
  71. ]
  72. )
  73. }
  74. }
  75. }