Jenkinsfile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. pipeline {
  2. agent { label 'windows-host' }
  3. environment {
  4. DOTNET_CLI_TELEMETRY_OPTOUT = '1'
  5. JAVA_TOOL_OPTIONS = '-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8'
  6. }
  7. stages {
  8. stage('Build') {
  9. steps {
  10. bat 'chcp 65001 && dotnet publish Web.Api -c Release -o publish\\api'
  11. bat 'chcp 65001 && dotnet publish Admin -c Release -o publish\\admin'
  12. }
  13. }
  14. stage('Stop Services') {
  15. steps {
  16. bat 'chcp 65001 && sc.exe stop bitforum-Api || exit 0'
  17. bat 'chcp 65001 && sc.exe stop bitforum-Admin || exit 0'
  18. bat 'ping 127.0.0.1 -n 6 > nul'
  19. }
  20. }
  21. stage('Deploy API') {
  22. steps {
  23. bat 'chcp 65001 && robocopy publish\\api H:\\IIS\\bitforum-api\\sources /MIR /XF web.config restart.ps1 /NFL /NDL /NP & if %ERRORLEVEL% LEQ 7 exit /b 0'
  24. }
  25. }
  26. stage('Deploy Admin') {
  27. steps {
  28. bat 'chcp 65001 && robocopy publish\\admin H:\\IIS\\bitforum-admin\\sources /MIR /XF web.config restart.ps1 /NFL /NDL /NP & if %ERRORLEVEL% LEQ 7 exit /b 0'
  29. }
  30. }
  31. stage('Start Services') {
  32. steps {
  33. bat 'chcp 65001 && sc.exe start bitforum-Api'
  34. bat 'chcp 65001 && sc.exe start bitforum-Admin'
  35. }
  36. }
  37. }
  38. post {
  39. success { echo 'Backend deploy success!' }
  40. failure { echo 'Backend deploy failed!' }
  41. }
  42. }