Deploy an Application on Server using Jenkins - jenkins

I'm new to Jenkins, i've build the dotnet application in jenkins using microsft publish command now i want to move the exe of the application from local system (where jenkins is installed) to a actual server. how to do it? how can i move code from my local system to server. Can anyone please guide me.
One way is to zip the exe and manually deploy it on server i want to automate it.

I believe you're looking to:
Deploy your application to an Azure Virtual machine
And also automate the process
For #1: I would highly recommend using Visual Studio to publish your app to the Azure VM from your local machine for ad-hoc deployments, unless you have a hard dependency on using Jenkins.
For #2: There are a few ways in which you can do this. Here are some great resources to refer:
Deploy to a Windows Virtual Machine
Migrate an ASP.NET Web application to an Azure Virtual Machine
Deploy your ASP.NET app to Azure virtual machines by using Azure DevOps Starter
Here is another detailed blog that walks one through the CI/CD setup using Azure DevOps.

Related

TFS Deploy Agent

I was trying to deploy my site using TFS release definition. For hosting the the site I am using MSDeploy Package Sync. Everything is fine but my hosted machine was in VPN so its showing below error while deploying throw TFS:
[error]System.Management.Automation.RemoteException: More Information: Could not connect to the remote computer ("developeriis"). Make sure that the remote computer name is correct and that you are able to connect to that computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINAT .
Same was working from my local machine which was connected to VPN. My question where should I add VPN details in TFS release definition?
There isn't a way to add the vpn details in TFS release definition. Seems you need to add the Hosted Agent machine to your VPN, obviously it's not available.
As a workaround you can try to deploy your own private agents that locates on your local machine or any other VMs within your VPN.
Then try to use the Private Agent for the deployment.
You can reference this thread:
Deploy from Visual Studio Team Services to on-prem IIS - VPN connect

Install Jenkins as a Service or Run it behind Apatche

I understand that there are two ways of installing Jenkins:
1) Running Jenkins behind Apache (Using the War file)
2) Installing Jenkins as a Windows Service(using the windows Installer)
I am in the process of creating a CI, Auto-Deployment and Scheduled Automation runs for my project. So in this case which kind of installation should be better. I just do not want to choose the wrong one and end up recreating jobs to the other kind.
I have few questions:
1) If I choose to install as a Windows service( using the windows installer), do I still have to install an web server like IIS or Apatche for accessing my Jenkins URL, or does Jenkins have something inbuilt in it and I do not have to add an web server for accessing Jenkins?
2)If Jenkins as a Windows Service(using the windows Installer) needs IIS, I have steps in my project in which I have to restart IIS manually to generate NCover reports. In such cases, would Jenkins also be down?
3) Jenkins website states the following: "In situations where you have existing web sites on your server, you may find it useful to run Jenkins (or the servlet container that Jenkins runs in) behind Apache, so that you can bind Jenkins to the part of a bigger website that you may have.".
I would be hosting our application locally using IIS, in that case, should I chose to use the WAR installer instead of the windows installer.
I do not run Jenkin's on Windows but I believe its the same as other platforms...
No if you install Jenkins with the installer you will not need IIS or Apache
See the answer to 1, If you don't use IIS to run Jenkins restarting it won't bring down Jenkins
It sounds like you want to run your existing site under IIS and leave Jenkins running on its own. I think the windows installer for Jenkins will do exactly this.
I have run Jenkins on Windows and Unix environment.
Just wanted to add more to Ben's answer:
Windows if you install as windows service you will not need anything and for this following wiki should be more than enough:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service
To add more to 3rd point:
Normally web sites are hosted behind Apache httpd server. If you are using one then you can configure both IIS web server and Jenkins accordingly.
In my previous company, we was running Jenkins as a service (with the solution proposed by Vinay above).
It worked well and you don't have to install an application server like Apache.
The only thing you have to take care is the user which launch the Windows service.
If your Jenkins server needs to access some ressource on the network, maybe you have to use a LDAP user to launch your service instead of using the "local system account".

Using TFS Build to run .bat files on remote server

The project I am on is using TFS Build in conjunction with Web Deploy to handle the deployments of the web site and service to the servers. We also have a windows service that needs to be deployed to the server as well.
My question is: Is there a way to deploy the Windows Service to the Web Server from the TFS Build server?
The other issue I have is that the service needs to be stopped before it can be deployed. I have tried to modify the Build Configuration file, but could not manage to get it to work.
Thanks.
Options:
If you install TFSBuildagent service on the web server and grant the user which runs the service Admin rights on the web server, then you can create a new build definition just for the deployment/installation. This is fairly simple and straight forward, but this would only work when you have limited number of web servers (who wants to install TFS BUild agent on all 2000 servers) and only work in the non-prod environment. This is how we are doing it for non-prod deployments, I have created a build definition which is just for deployment, which takes care of all the things like stopping services etc.
If the user which runs the TFSBuild Service on the build server have enough rights on the web server then you can use psexec or powershell to run your commands remotely. Read the below links: 1. PSEXEC
Powershell Remote commands
What did you do to stop the service in your build configuration file? Does the user have enough rights?
There is no inbuilt activity/process which can help you run scripts on remote machines in TFS build workflow.
Step 1 for you is to identify how you are going to run scripts on the remote machine, as mentioned above you can either use PSEXEC or Powershell (though running PowerShell on remote computers may be a little more complicated to set up).
Step2, write the actual scripts to do the work, stop services, install MSI etc.
Step3, Edit your current build defintion - create a new custom activity or make use of InvokeProcess activity from within your build definition to invoke the script that you have created in Step 2. InvokeProcess Activity

Deploying asp.net MVC application

I've an ASP.NET MVC-2 Website, which is running perfect at my development machine(IIS-7, Win7).
When I copied my full website to remote server(Windows Hosting with .net 4.0), it displays Error-404.
Can you pls assist me to deploy it in remote host machine.
Your question is a bit broad, but for a start might I suggest not manually copying the files over to the new environment (acceptance, production, QA...etc.) as a "deployment mechanism".
Ideally you want to setup a continuous build system which allows you to automatically build your project(s), apply the correct configuration, package and deploy it.
Troy Hunt wrote an excellent 5-part series in which he explains how to create such a setup using TeamCity, Subversion, MSBuild, Web.Config Transformations and Web Deploy.
You can check out the series 'You're deploying it wrong! TeamCity, Subversion & Web Deploy' here:
Part 1: Config transforms
Part 2: MSBuild and deployable packages
Part 3: Publishing with Web Deploy
Part 4: Continuous builds with TeamCity
Part 5: Web Deploy with TeamCity
Of course the same setup is achievable using other software packages (e.g.: Team Foundation Server instead of TeamCity...etc.).
After you've deployed your site using Web Deploy (to a primary server), you can also use the Web Farm Framework to synchronize all of the servers in the farm. You want to avoid manual actions during deployment. Sure you can get all the steps (copying files, adjusting configuration files, synchronizing servers...etc.) correct, but in the long run mistakes are unavoidable.

Command-line to "deploy" ASP.NET MVC project

I am using Visual Studio Team Suites to develop a ASP.NET MVC project. I can deploy the web app to my dev machine using the "deploy" item from IS. Is there a command-line tool to do this task? What I am trying to do is to setup a continuous integration server (using TeamCity Pro), so that whenever I checkin new code, I will get a new build, deploy to a remote IIS server, and then run tests on the testing server.
Thanks,
-Yi
It looks like Microsoft have such a deployment tool. Never used it myself.
Scott Hanselman has blogged about it here
MSDeploy, Microsoft's upcoming command-line deployment tool (which will be integrated into VS2010) is currently available in Beta2.
Info:
http://learn.iis.net/page.aspx/346/web-deployment-tool/
Download (x86):
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1602
Download (x64):
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1603
Also, if you have disk access to the servers you want to deploy to from the CI server and don't need to install/remove things from the GAC or tweak the IIS metabase, plain old robocopy is a great option.

Resources