Initiating node server, undertaking another task, then shutting down server on Gitlab CI

I have set up a GitLab Runner using Shell and my gitlab-ci.yml file includes the following configuration. In the before_script section, it installs necessary packages and starts the node server using "start npm run start" to prevent it from getting stuck at "server started at xxxxxxx". However, when I execute this command, it stops the node.exe processes successfully but then remains hanging indefinitely. I have to manually cancel the build as it never progresses to the after_script section.

Test:
  before_script:
    - call npm install
    - start npm run start
  script:
   - waitfor SomethingThatIsNeverHappening /t 3 & taskkill /t /f /im node.exe & exit 0
  after_script:
    - echo HELLLLLLLLLLO

My query is how can I modify this code to achieve the desired outcome? I aim to start the server, perform certain tasks, and then terminate the server, while ensuring that the build concludes successfully with the appropriate status (failed or passed) on GitLab. Currently, everything in the file executes but the application keeps hanging post processing instead of completing successfully and displaying the correct outcome. Even if I remove the after_script section, it still hangs endlessly.

Note: I have attempted using exit 0 and exit 1 without any success.

Relevant Log:

$ start npm run start

$ waitfor SomethingThatIsNeverHappening /t 3 & taskkill /t /f /im node.exe & exit 0

ERROR: Timed out waiting for 'SomethingThatIsNeverHappening'.

SUCCESS: The process with PID 2396 (child process of PID 9196) has been terminated.

SUCCESS: The process with PID 10040 (child process of PID 9196) has been terminated.

SUCCESS: The process with PID 8452 (child process of PID 9196) has been terminated.

SUCCESS: The process with PID 11172 (child process of PID 9196) has been terminated.

SUCCESS: The process with PID 5416 (child process of PID 9196) has been terminated.

SUCCESS: The process with PID 9196 (child process of PID 8648) has been terminated.

SUCCESS: The process with PID 8648 (child process of PID 8272) has been terminated.

SUCCESS: The process with PID 8272 (child process of PID 8512) has been terminated.

After this point it just keeps running forever without another line of new output

Answer №1

After making the switch to powershell as my preferred shell, following the instructions in the config.toml file located in the runner directory, I successfully resolved the problem at hand. By translating the commands into powershell-compatible syntax, all tasks were completed without any issues.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Controlling Dependencies within SailsJS

Is there a way to effectively handle dependencies in a Sails.JS project? I have been utilizing the convenient feature that automatically connects assets from the assets folder to the appropriate templates. However, when I use bower / npm install to acqui ...

Using command line arguments to pass parameters to package.json

"scripts": { "start": "gulp", ... }, I have a specific npm package that I'm using which requires passing parameters to the start command. Can anyone help me with how to pass these parameters in the command line? For example, is it possible ...

What is the best way to combine relative paths or create distinct identifiers for SVG files located within multiple layers of folders

I have a collection of icons exported from "Figma" organized in folders, and I'm using grunt-svgstore to create a sprite sheet. However, the result contains duplicated IDs even after trying 'allowDuplicateItems: false' and 'setUniqueIds ...

Jenkins does not have the capability to execute npm or pm2 independently

Currently, I have a Jenkins CI setup running on an EC2 server. I've successfully installed nodejs and npm. Interestingly, Jenkins is able to access them via the command line using this command: sudo -u jenkins node -v However, when it comes to actua ...

The npx create-react-app command fails to create a React app

Attempting to generate a new React application using the command npx create-react-app myapp on my computer is proving unsuccessful. Here's what I encountered: When running the command D:\AED>npx create-react-app aed, it took 52.503 seconds to in ...

When using npm or yarn, running the command `node-gyp rebuild` may result in an error with an exit status

Having an issue while using yarn on Windows. I've tried versions 12.13.1, *10.16.0 (currently using a 64-bit executable), and 9.11.2. The error message I'm getting is: Error C:\XXX\node_modules\node-expat: Command failed. Exit cod ...

Sending the user to their destination

There is a code in place that triggers when an email is sent to the user, containing a link that leads them to a specific endpoint upon opening. I am experiencing issues with redirection at the end of the function. The redirect does not seem to be working ...

The error message "Docker and npm - gyp ERR! not ok" indicates that

Client operations were running smoothly until I encountered an issue with Network disconnected, which prompted me to upgrade react-scripts in my docker client service from version 3.0.1 to 3.3.0. I used the command npm install <package> --save and re ...

How to Override package.json Scripts in NPM

Is it possible to modify package.json scripts without changing the original file? I need to customize the memory allocation for a specific step, but altering the package.json will affect everyone. For example, our current script is: "script": { "dev": ...

Execute multiple JavaScript files dynamically by utilizing the same npm run command

My directory structure: app Model user.js post.js Contents of my package.json file: "scripts": { "migrate": "node ./app/Model/" } I am looking to execute JavaScript files via command line in a dynamic manner. For example: npm run migr ...

where is the yarn global registry located?

After updating yarn to point to my custom registry and verifying the changes, here is what I found: $yarn config list -g yarn config v1.22.10 info yarn config { 'version-tag-prefix': 'v', 'version-git-tag': true, ' ...

Having trouble with creating a new Next.js app using the latest version with npx?

Having some difficulty with the "npx create-next-app@latest" command while setting up Next.js. As a newcomer to both the community and Next.js, I could use some assistance in resolving this problem. Upon running the command, an unfamiliar message was displ ...

Encountering issues while trying to download cordova using npm

While attempting to install cordova using npm, I kept encountering the ETIMEDOUT error. Can anyone provide guidance on how I can successfully complete the installation? npm install -g cordova error ...

Having trouble cloning the git repository even after updating npm to the latest version

After installing the latest version of node and npm, I encountered an issue when trying to clone a git repository. The error message received was: "'git' is not recognized as an internal or external command, operable program or batch file." E ...

Muting error messages during npm run-script failures

Running npm test results in test outputs along with a single error message if it fails: npm ERR! Test failed. See above for more details. However, I created a custom script named lint: // package.json { // ... "scripts": { // ... definition for ...

Troubleshooting the transition from React version 16.0.0 to React version 18

I am encountering issues with my package.json file and Jenkins build, which fails due to the following problems. I'm currently running npm version 8.15.0 and Node version v16.17.1, while trying to upgrade from React 16 to React 18. package.json { & ...

unable to execute a node.js demonstration

When attempting to run a pre-existing example in the node.js environment, I consistently encounter the error message: "Cannot find module '/build/default/validation'" Could it be possible that I forgot to install a certain module using npm? ...

Is it possible to execute npm commands on the Azure App console?

I'm encountering an error message whenever I attempt to execute any npm command (such as npm i) on a Windows Azure app console. The environment consists of Node v10.19.0 and Npm v6.13.4. https://i.stack.imgur.com/QyKZC.png Here is the formatted code ...

Having trouble resolving npm install -g @angular/cli due to issue with checking the installable status of [email protected] module

When attempting to install @angular/cli using the npm command in the command prompt, I encountered an issue with resolveWithNewModule. It seems to be stuck at checking installable status.[email protected] ...

Export and import global npm packages in your project

Looking to start fresh, I want to completely reinstall npm. After the reinstallation, I need a safe and automated method to export and import the globally installed packages from the old npm installation. It's worth noting that my previous npm install ...