MSDeploy with Jenkins

asp.netJenkinsmsdeploy

So I'm setting up a Jenkins job that will build and deploy an application that I have. Building it is easy, but I'm having issues deploying it.

Here is my build command:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "AppName\AppName.csproj" /T:Build;Package /p:Configuration=DEBUG /p:OutputPath="obj\DEBUG" /p:DeployIisAppPath="/sub.domain.com/AppName" /p:VisualStudioVersion=14.0

sub.domain.com is the website name on IIS, and AppName is an application under it.

Now here is mostly my deploy command which doesn't work:

"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package="AppName\obj\Debug\_PublishedWebsites\AppName_Package\AppName.zip" -dest:auto,computerName="https://webserver:8172/msdeploy.axd",username=jenkins,password=jenkins,authType=basic -allowUntrusted=true

Now in IIS I have a manager user set up with the above credentials and has permissions over both the site and application. But whenever I run this command I end up getting a ERROR_USER_UNAUTHORIZED message.

What do I need to change in my deploy command to get it so I can deploy to the web server?

Thanks!

Best Answer

If your deployment user is not an administrator, than it shall be added as management user to IIS site (let assume that it is named "my_iis_site"), it shall have enough file system permissions for site folder (modify/delete/create at least) and your deployment command shall show to handler that you are going to execute in scope of this site:

"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package="AppName\obj\Debug\_PublishedWebsites\AppName_Package\AppName.zip" -dest:auto,computerName="https://webserver:8172/msdeploy.axd?site=my_iis_site",username=jenkins,password=jenkins,authType=basic -allowUntrusted=true

So, the trick is to pass to msdeploy.axd handler site name as a query string 'site=my_iis_site'