Jenkinsfile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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('Checkout') {
  9. steps {
  10. checkout scm
  11. }
  12. }
  13. stage('Build') {
  14. steps {
  15. bat 'dotnet publish Web.Api -c Release -r win-x64 -o publish\\api'
  16. bat 'dotnet publish Admin -c Release -r win-x64 -o publish\\admin'
  17. }
  18. }
  19. stage('Stop Services') {
  20. steps {
  21. bat 'sc.exe stop bitforum-Api || exit 0'
  22. bat 'sc.exe stop bitforum-Admin || exit 0'
  23. bat 'ping 127.0.0.1 -n 6 > nul'
  24. }
  25. }
  26. stage('Deploy API') {
  27. steps {
  28. bat 'robocopy publish\\api H:\\IIS\\bitforum-api\\sources /MIR /XF web.config restart.ps1 /NFL /NDL /NP & if %ERRORLEVEL% LEQ 7 exit /b 0'
  29. }
  30. }
  31. stage('Deploy Admin') {
  32. steps {
  33. bat 'robocopy publish\\admin H:\\IIS\\bitforum-admin\\sources /MIR /XF web.config restart.ps1 /NFL /NDL /NP & if %ERRORLEVEL% LEQ 7 exit /b 0'
  34. }
  35. }
  36. stage('Start Services') {
  37. steps {
  38. bat 'sc.exe start bitforum-Api'
  39. bat 'sc.exe start bitforum-Admin'
  40. }
  41. }
  42. }
  43. post {
  44. success { echo 'Backend deploy success!' }
  45. failure { echo 'Backend deploy failed!' }
  46. }
  47. }