Add dotnet-ef tool manifest and dev Jenkinsfile for CI

This commit is contained in:
2026-04-24 09:03:23 -04:00
parent 63e12a9636
commit 6ddf428c10
2 changed files with 99 additions and 0 deletions
+86
View File
@@ -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.'
}
}
}