First, start with build agents, where you can edit the buildAgent.properties file and define 3 environment variables. You should have surrounding single quotes here or later in your assembly definitions:
env.exec.node='C\:\\Program Files\\nodejs\\node.exe' env.exec.npm='C\:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js' env.exec.ng='%env.APPDATA%\\npm\\node_modules\\@angular\\cli\\bin\\ng'
%env.APPDATA% used %env.APPDATA% , but some settings can be set in Program Files, in most cases it is AppData.
Next, you can define the build steps for your project. Create these new build steps of type Powershell and set Script as the source code. Inside the Script Source, you can now enter:
Set Angle CLI
& %env.exec.node% %env.exec.npm% install -g @angular/cli
Set node_modules folder
& %env.exec.node% %env.exec.npm% install
Build and publish solution
& %env.exec.node% %env.exec.ng% build --environment '%env.build.environment%' --scripts-prepend-node-path
After this step, production assemblies will create your dist folder, which you can include in the artifact paths so that you can access it if you want to create separate assembly configurations of deployment type.
Some considerations to consider here:
- You can define variables inside yours, however different agents can be used in assembly agents, which will slow down your assemblies
- Make sure you have the proper cleanup rules as the node_modules folders can become very large
Hope this helps someone!
source share