17

My problem is that I need to run a custom cmd file after the build. Instead of modifying the deployment scripts I just want to run few MSDOS commands to my deployment easily.

The task I need to do is to run a cmd at the repository located at /source/copyextrafiles.cmd after the build succeeded.

How can I achieve that?

leocrimson
  • 702
  • 1
  • 11
  • 25
regisbsb
  • 3,664
  • 2
  • 35
  • 41

2 Answers2

15

At the azure portal on the CONFIGURE tab of your website add a "app settings" entry called POST_DEPLOYMENT_ACTION with the value of source/copyextrafiles.cmd Save and the next deploy will run the cmd for you after the deploy.

Here the picture: enter image description here

regisbsb
  • 3,664
  • 2
  • 35
  • 41
  • Works like a charm! I use it to invoke gulp to build my static assets after my Python site has been deployed. Is there a smarter way to do this? – Andrei Bârsan Feb 06 '15 at 12:34
  • Where do I add the cmd file? I am hosting a .Net application with sturcture like D:\home\site\wwwroot – Mrinal Saurabh Aug 17 '15 at 11:59
  • that path will be relative to the root of the source it's not relative to the wwwroot – regisbsb Aug 17 '15 at 12:10
  • 1
    This has been slightly updated since the answer: https://github.com/projectkudu/kudu/wiki/Post-Deployment-Action-Hooks The app setting is called `SCM_POST_DEPLOYMENT_ACTIONS_PATH` and the value is a folder, where all bat/cmd/ps1 scripts will be executed. – Adam Szabo Oct 28 '17 at 12:45
  • 3
    @AdamSzabo What if I want to run one specific ps or exe file located in wwwroot\bin directory? Or how to automatically deploy such scripts to site\deployments\tools\PostDeploymentActions directory? – Evgeni Nabokov Nov 03 '17 at 21:44
5

An alternative in addition to the solutions already provided is to copy the script in to a specific folder provided for post deployment action hooks.

So after creating a new directory in "D:\home\site\deployments\tools\" named "PostDeploymentActions", you could just add script files (.bat, .cmd or .ps1) into the directory and they will all run, one by one, after each deployment.

Ole Kristian Losvik
  • 1,133
  • 3
  • 20
  • 32