From 6ddf428c1050f354a9808ef086eb35c7527590f2 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Fri, 24 Apr 2026 09:03:23 -0400 Subject: [PATCH] Add dotnet-ef tool manifest and dev Jenkinsfile for CI --- Jenkinsfile.dev | 86 +++++++++++++++++++++++++++++++++++++++++++++++ dotnet-tools.json | 13 +++++++ 2 files changed, 99 insertions(+) create mode 100644 Jenkinsfile.dev create mode 100644 dotnet-tools.json diff --git a/Jenkinsfile.dev b/Jenkinsfile.dev new file mode 100644 index 0000000..eeaaf8c --- /dev/null +++ b/Jenkinsfile.dev @@ -0,0 +1,86 @@ +pipeline { + agent { label 'appdev' } + + environment { + DOTNET_CLI_HOME = "C:\\Windows\\Temp" + PUBLISH_DIR = "C:\\jenkins\\publish\\powdercoating" + DEPLOY_DIR = "C:\\inetpub\\wwwroot" + APP_POOL = "PCC" + WEB_PROJECT = "src\\PowderCoating.Web\\PowderCoating.Web.csproj" + INFRA_PROJECT = "src\\PowderCoating.Infrastructure\\PowderCoating.Infrastructure.csproj" + CONNECTION_STRING = "Server=.\\SQLEXPRESS;Database=PowderCoatingDb;Trusted_Connection=true;MultipleActiveResultSets=true;TrustServerCertificate=true" + } + + stages { + + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Restore') { + steps { + bat 'dotnet restore' + } + } + + stage('Build') { + steps { + bat 'dotnet build --no-restore -c Release' + } + } + + stage('Test') { + steps { + bat 'dotnet test --no-build -c Release --logger "trx;LogFileName=results.trx" --results-directory TestResults' + } + post { + always { + junit testResults: 'TestResults/*.trx', allowEmptyResults: true + } + } + } + + stage('Publish') { + steps { + bat "dotnet publish %WEB_PROJECT% -c Release --no-build -o \"%PUBLISH_DIR%\"" + } + } + + stage('Migrate Database') { + steps { + bat """ + dotnet tool restore + dotnet ef database update --project %INFRA_PROJECT% --startup-project %WEB_PROJECT% --connection "%CONNECTION_STRING%" + """ + } + } + + stage('Deploy') { + steps { + // Stop app pool, copy files, restart app pool + bat """ + C:\\Windows\\System32\\inetsrv\\appcmd stop apppool /apppool.name:%APP_POOL% + xcopy /E /Y /I "%PUBLISH_DIR%\\*" "%DEPLOY_DIR%\\" + C:\\Windows\\System32\\inetsrv\\appcmd start apppool /apppool.name:%APP_POOL% + """ + } + post { + failure { + // Make sure app pool is restarted even if copy fails + bat 'C:\\Windows\\System32\\inetsrv\\appcmd start apppool /apppool.name:%APP_POOL%' + } + } + } + } + + post { + success { + echo 'Dev deployment completed successfully.' + } + failure { + echo 'Pipeline failed — check logs above.' + } + } +} diff --git a/dotnet-tools.json b/dotnet-tools.json new file mode 100644 index 0000000..ce0aab7 --- /dev/null +++ b/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "10.0.7", + "commands": [ + "dotnet-ef" + ], + "rollForward": false + } + } +} \ No newline at end of file