How to run npm command on azure app service after deployment success by VSTS?

后端 未结 5 1407
臣服心动
臣服心动 2021-01-18 12:02

Now I can deploy from VSTS to azure, but I can\'t run npm after deploy is successful.

Now it is work like -> run npm install for branch files => zip => copy to azure

相关标签:
5条回答
  • 2021-01-18 12:38

    You can use PowerShell task or npm task to execute npm commands .

    One thing to note: you also need to upload the .npmrc with auth token to Azure.

    0 讨论(0)
  • 2021-01-18 12:47

    There is no out of box build task to achieve the feature you want. If you do want to run the npm from Azure App Service:

    Manually: You can go to Kudu console of the App Service and run npm command there:

    Automatically: You need to create your own build task to run the npm command via Kudu Rest API

    0 讨论(0)
  • 2021-01-18 12:48

    The Kudu deployment engine that App Service leverages has the ability to run custom deployment scripts. You can include your desired npm command inside of a custom deployment script that will be executed as part of the deployment on Azure's side. No REST API calls required and everything stays in your source control system.

    0 讨论(0)
  • 2021-01-18 12:51

    The Azure App Service Deployment task in VSTS now supports a post-deployment script. Here is a screen-shot from version 3.* of the task:

    See Task Parameters for more details.

    Windows App Services users: Watch out for an npm bug that prevents multiple npm commands from being run (inline or in a script). For example:

    npm install
    npm test
    

    Will only run npm install. There are several workarounds including this:

    npm install & npm test
    
    0 讨论(0)
  • 2021-01-18 12:57

    You can run commands like npm install via the Kudu REST API.

    Here's a scripted example written in PowerShell.

    Add a PowerShell script task after the Azure App Service Deploy task to invoke npm install (or any other command that Kudu supports). And disable the npm install task in your build pipeline.

    0 讨论(0)
提交回复
热议问题