1

I want to run a CI/CD pipeline on Azure to build and release a nodejs webapp on a self-hosted machine. I have successfully set up a pipeline to checkout the code, build it and publish the artifacts. Now I want to have a release pipeline that downloads the artifacts created in the build pipeline, deploy it to a deployment group and start the app with npm start.

I can manage all the steps except the last one. I have tried adding a custom "npm start" task to the Deployment group job. Azure pipeline gets to that step and then hangs. I guess it just waits for the command to finish, which will not happen, since this is starting the server.

Any idea how to do this?

2 Answers 2

1

npm start is the equivalent of running whatever value is specified in the scripts( start attribute of the package.json file). So you first need to check your package.json file.

There is a speculation in this case with similar issue:

the npm start must keeps running so that it can be used all the time. So the command is never finished. The workaround is using cmd task to start another cmd task and run the npm start command in new cmd.

Sign up to request clarification or add additional context in comments.

4 Comments

Indeed, in my case being "react-scripts start". This starts the server which waits for incoming connections.
It is helpful, but it doesn't get the job done, so unfortunately I cannot accept it.
Do you try to use cmd task to start another cmd task and run the react-scripts start in new cmd?
Yes, didn't work for me. Both tasks were killed after 10 seconds. Bu anyway, I found a better approach, see answer.
1

I ended up with what I think it's a better solution: I use pm2 with --watch. Azure DevOps just copies the files to the folder where pm2 is watching.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.