Applications built using Angular for the frontend and ASP.NET Core for the backend are frequently deployed by hand, requiring file copies, Visual Studio publishing, IIS restarts, and other steps. Manual deployment becomes dangerous as your team increases, although it works well for small projects. One minor error could overwrite settings or result in downtime.
Jenkins' Continuous Integration and Continuous Deployment (CI/CD) technology can help with it.
Every time you push code, it swiftly and safely builds, tests, and deploys your project. I'll walk you through the process of utilizing the Jenkins pipeline to deploy a full-stack application (Angular + ASP.NET Core) on a Windows server (IIS) in this post.
Requirements
Before we start, make sure you have:
Installed Jenkins (Windows or Linux)
Installed .NET SDK (e.g. .NET 8.0) on the Jenkins server
Installed Node.js and Angular CLI
Installed Git (for source code checkout)
Access to your IIS server for deployment
Project Structure
Below is a common folder structure we’ll work with:
Step 1. Create a Jenkins Pipeline Job
Open Jenkins Dashboard → New Item → Pipeline
Give it a name, e.g.,
RajeshDemoApp-CI-CDUnder Pipeline definition, select Pipeline script from SCM
Choose Git, and provide your repo URL.
Jenkins will now read the
Jenkinsfilefrom your repository.
Step 2. Jenkinsfile Configuration
Here’s a simple Jenkinsfile example for our project:
Note:
If you’re using Linux agents, replace bat with sh.
Step 3. Create PowerShell Script for Deployment
Let’s create a PowerShell file named deploy.ps1 at the root of your repo.
This script will:
Stop IIS site
Backup old files
Copy new build files
Restart IIS site
Step 4. Handle Configuration Files
We usually have environment-specific files like:
appsettings.Production.jsonenvironment.prod.ts
You can use a small PowerShell snippet to replace these files based on environment before publishing.
Example:
Step 5. Run the Pipeline
Commit and push your code (including Jenkinsfile).
Go to Jenkins → click Build Now.
Jenkins will run each stage — build Angular, build .NET, deploy to IIS.
Step 6. Troubleshooting Tips
If deployment fails:
Check Jenkins console logs (very helpful).
Make sure IIS user has write permission to your deployment folder.
Ensure Node.js, Angular CLI, and .NET SDK paths are configured in Jenkins.
Step 7. Benefits of Using CI/CD
After setting this up once, your deployments become:
Automatic – no manual file copying
Consistent – same steps every time
Fast – 1-click deployment from Jenkins
Safe – automatic backup and rollback
Conclusion
By combining Jenkins, ASP.NET Core, and Angular, we can automate our entire deployment process.
No more “it works on my machine” issues — your build, test, and deployment happen exactly the same way every time.


0 comments:
Post a Comment