Jenkinsfile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. pipeline {
  2. agent { label 'windows-host' }
  3. environment {
  4. DOTNET_CLI_TELEMETRY_OPTOUT = '1'
  5. }
  6. stages {
  7. stage('Checkout') {
  8. steps {
  9. checkout scm
  10. }
  11. }
  12. stage('Build') {
  13. steps {
  14. bat 'dotnet publish Web.Api -c Release -o publish\\api'
  15. bat 'dotnet publish Admin -c Release -o publish\\admin'
  16. }
  17. }
  18. stage('Stop Services') {
  19. steps {
  20. bat 'sc.exe stop bitforum-Api || exit 0'
  21. bat 'sc.exe stop bitforum-Admin || exit 0'
  22. bat 'ping 127.0.0.1 -n 6 > nul'
  23. }
  24. }
  25. stage('Deploy API') {
  26. steps {
  27. 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'
  28. }
  29. }
  30. stage('Deploy Admin') {
  31. steps {
  32. 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'
  33. }
  34. }
  35. stage('Start Services') {
  36. steps {
  37. bat 'sc.exe start bitforum-Api'
  38. bat 'sc.exe start bitforum-Admin'
  39. }
  40. }
  41. }
  42. post {
  43. success { echo 'Backend deploy success!' }
  44. failure { echo 'Backend deploy failed!' }
  45. }
  46. }