Jenkinsfile 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 --registry=https://registry.npmmirror.com && npm run build'
  21. sh 'tar -zcf dist.tar.gz dist/'
  22. }
  23. }
  24. stage('deploy job') {
  25. steps {
  26. sshPublisher(publishers: [sshPublisherDesc(configName: 'WH-COOLESHOW-TEST', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: 'cd /mdata/www/h5-colexiu && rm -rf dist/ && tar -zxf *.tar.gz && rm *.tar.gz', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '/mdata/www/h5-colexiu', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '**/*.tar.gz')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
  27. }
  28. }
  29. stage('clean job') {
  30. steps {
  31. sh 'rm dist.tar.gz'
  32. }
  33. }
  34. }
  35. post {
  36. success {
  37. dingtalk (
  38. robot: "a346e21b-706e-4881-8e3b-6c48d16d0c3b",
  39. type:'ACTION_CARD',
  40. atAll: false,
  41. title: "构建成功:${env.JOB_NAME}",
  42. //messageUrl: 'xxxx',
  43. text: [
  44. "### [${env.JOB_NAME}](${env.JOB_URL}) ",
  45. '---',
  46. "- 任务:[${currentBuild.displayName}](${env.BUILD_URL})",
  47. '- 状态:<font color=#00CD00 >成功</font>',
  48. "- 持续时间:${currentBuild.durationString}".split("and counting")[0],
  49. "- 执行人:${BUILD_USER}",
  50. ]
  51. )
  52. }
  53. failure{
  54. dingtalk (
  55. robot: "a346e21b-706e-4881-8e3b-6c48d16d0c3b",
  56. type:'ACTION_CARD',
  57. atAll: false,
  58. title: "构建失败:${env.JOB_NAME}",
  59. //messageUrl: 'xxxx',
  60. text: [
  61. "### [${env.JOB_NAME}](${env.JOB_URL}) ",
  62. '---',
  63. "- 任务:[${currentBuild.displayName}](${env.BUILD_URL})",
  64. '- 状态:<font color=#EE0000 >失败</font>',
  65. "- 持续时间:${currentBuild.durationString}".split("and counting")[0],
  66. "- 执行人:${BUILD_USER}",
  67. ]
  68. )
  69. }
  70. }
  71. }