4

I have an ASP.Net application. I want to deploy to the remote Windows machine. I have a shared wwwroot folder. To deploy from cmd use the following command

c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" "C:\path_to_project" /p:SolutionDir="path_to_solution_dir" /p:DeployOnBuild=true /p:Configuration=Release /p:PublishProfile="Profile.pubxml"

The profile looks the following way

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
       <WebPublishMethod>FileSystem</WebPublishMethod>
       <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
       <LastUsedPlatform>Any CPU</LastUsedPlatform>
       <SiteUrlToLaunchAfterPublish />
       <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
       <ExcludeApp_Data>False</ExcludeApp_Data>
       <publishUrl>\\<ip_address>\wwwroot</publishUrl>
       <DeleteExistingFiles>True</DeleteExistingFiles>
   </PropertyGroup>
</Project>

From command line it work fine. But when I put the same thing into Jenkins pipeline script using Batch plugin, I get the next error

error MSB3191: Unable to create directory "\\<ip_address>\wwwroot". 
Could not find a part of the path '\\<ip_address>\wwwroot'

What's wrong with Jenkins? Are there any problems with configuration settings? Maybe I need to change the approach for deployment?

Liam
  • 27,717
  • 28
  • 128
  • 190
Pavel the coder
  • 565
  • 4
  • 18
  • Possible duplicate of [Jenkins can't access mounted driver](https://stackoverflow.com/questions/10295759/jenkins-cant-access-mounted-driver) There are some clues, check it :) Maybe try to mount it manually- via `net use` command at windows before using – xxxvodnikxxx May 14 '18 at 12:28
  • @xxxvodnikxxx, I haven't tried it yet, because server is temporarily down. Is there a way to use just shares instead of mouted drives? – Pavel the coder May 14 '18 at 15:09
  • Have no idea, but I guess if the server will be down, then it doesnt matter which case will you try to use – xxxvodnikxxx May 15 '18 at 06:50

3 Answers3

2

Solved exactly for this approach back in 2015/16.

This was my setup:

  1. Publish Profile per target environment on the web projects to be deployed to remote (from the point of view of the Jenkins master) IIS sites.
  2. Web.config transform file for each target environment
  3. Web Deploy 3.6 installed on the target IIS machine.
  4. Ensured I get the "green tick" to prove connectivity in Publish Profile. (Note you may have to reinstall Web Deploy to get this working properly. For some reason Web Deploy doesn't install correctly the first time)
  5. Strict naming standards on profile names, IIS site names and AppPool names so everything matched.
  6. I did 5 so I could pass parameters from a Jenkins Windows Batch step (this was a freestyle job before I fully migrated to pipeline in current role which started in Jan 2018) to two DOS batch script I wrote to

    a) Remotely control target IIS (start/stop sites and AppPools)

    b) Remotely delete the current contents of site before MSBuild redeployed via Publish Profile and the MSBuild /p:DeployOnBuild.

I utilitised PSExec to achieve the "remote" capability and called it as part of the DOS batch scripts.

I'm sure you could achieve the same thing with Powershell but the principles are the same.

Andrew Gray
  • 3,593
  • 3
  • 35
  • 62
1

check the value of the parameter is getting resolved. Also check the account with which Jenkins is running has privilege to the shared folder. We too have similar requirement, considering the network dependency and limit on parallel execution we installed agents in the respective boxes and we do local deployments using the Jenkins slave

Ashokekumar S
  • 351
  • 3
  • 7
  • I changed the user running the service with luck, this allowed me to publish to the shared folder. Is this approach safe and desirable? – Gabriel Espinoza Aug 25 '18 at 01:52
0

Try and switch <publishUrl>\\<ip_address>\wwwroot</publishUrl> to your directory.

JosephWorks
  • 682
  • 4
  • 21