There is a nodovskiy script that I can run from the project root directory (also known as WORKSPACE for Jenkins)

node ./scripts/rebuild.js 

But how do I write it as a Powershell script in the build step for Jenkins. I guess that the executable script needs to be specified relative to WORKSPACE, and what to do with the node.

The node file is located here.

 C:\Program Files\nodejs\node.exe 

Does it need to be entered into env or into parameters?

This ps script returns an error.

 &"node $ENV:WORKSPACE\scripts\rebuild.js" 

Can you please tell me how to fix it?

  • one
    You can add a path to ENV , or you can try Windows Exe Runner , add a variable and a path, and in a job add a step with the parameters of what to run. - approximatenumber
  • @approximatenumber yes, thanks. rewrote the script and mentioned the use of project parameters in the response - while1pass

1 answer 1

The final script should look like this.

 $NODE = "C:\Program Files\nodejs\node.exe" &"$NODE" .\scripts\rebuild.js 

enter image description here You can also add a NODE variable to your project settings and access it as &"$ENV:NODE" .\scripts\rebuild.js . enter image description here Or in Jenkins settings to use it on multiple projects.

The use of parameters reduces the amount of scripts and allows you to change the logic immediately everywhere, without tracking where this parameter was used