0

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!

Chiggins
  • 811
  • 8
  • 21
  • 37

1 Answers1

1

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'

Anton Kuryan
  • 193
  • 1
  • 9
  • Right on! So my question now is, since I'm publishing to an application under a site, do I need to specify that all in the msdeploy command? So if my application is my_iis_site/AppName, does that get specified? – Chiggins Mar 23 '16 at 19:06
  • Have not used such a scenario before - but, following logic my_iis_site/AppName shall work – Anton Kuryan Mar 23 '16 at 19:20
  • Now I'm getting an ERROR_USER_NOT_AUTHORIZED_FOR_IISAPP – Chiggins Mar 28 '16 at 19:40
  • Can you check and post error in you event log from MsDeploy provider? Cause it is hard to say what's the problem, basing on MsDeploy error code - they are pretty bad. Also, IMHO, it is worth checking this post: http://forums.iis.net/post/2042792.aspx – Anton Kuryan Mar 29 '16 at 18:30
  • Here's what I'm getting from the eventlog http://pastebin.com/B5pFNPxA – Chiggins Mar 29 '16 at 19:58
  • The command works when I run as one of my admin accounts, but I'd rather run it as a service account. And in IIS the service account has permissions in both my site and application, and is added to iisApp service delegation. – Chiggins Mar 29 '16 at 20:00
  • You are running msdeploy as admin account, or you are connecting to msdeploy.axd handler with admin account? Can you create a user, delegate him access to IIS site you are deploying too and try with it? – Anton Kuryan Mar 29 '16 at 21:52