How to use angular cli on Windows Server in the Jenkins build batch team

before installing Jenkins I ran this: npm install -g @ angular / cli

but I also have this in devDependencies in package.json for the project:

"@ angular / cli": "1.0.0-beta.32.3" ,


when I start the Jenkins build, I get this message in the log:

'ng' is not recognized as an internal or external command, operating program, or batch file.

=========================================

Here is the Windows command command in Jenkins:

cmd / c npm install call

set Path =% WORKSPACE% \ node_modules \ @angular \ cli \ bin;% PATH%

echo% PATH%

ng build -prod

==========================================

here is a bit more log output from Jenkins:

C: \ Program Files (x86) \ Jenkins \ workspace \ UiUnitTests> ng build -prod

'ng' is not recognized as an internal or external command, operating program, or batch file.

C: \ Program Files (x86) \ Jenkins \ workspace \ UiUnitTests> exit 9009 Build the "Run Windows Command" step is marked as a failure


but when I run it only from the command line (not in Jenkins task), this works fine:

C: \ Program Files (x86) \ Jenkins \ workspace \ UiUnitTests> ng build -prod

Your global version of Angular CLI (1.0.0-rc.1) is larger than the local

version (1.0.0-beta.32.3). The local version of the Angular CLI is used.

To disable this warning, use "ng set - global warnings.versionMismatch = false". Hash: 7853ecb5a81a25eadbeb Time: 61317ms chunk {0} polyfills.7aaf5284cd5921eea40b.bundle.js (polyfield) 278 kB {4} [initial] [rendered] chunk {1} main.3380f71d3e71966aea27.bundle.js (3) [initial] [provided] chunk {2} styles.9db1bafdfc989b37db97.bundle.css (styles) 69 bytes {4} [initial] [rendered] chunk {3} vendor.24574fc8320129058fac.bundle.js (provider) 2.18 MB [ initial] [rendered] chunk {4} inline.d1f5b52100bed2568d44.bundle.js (inline) 0 bytes [record] [displayed]

C: \ Program Files (x86) \ Jenkins \ workspace \ UiUnitTests>

================================================= =

last but not least: here is the Jenkins log output from echo% PATH%

C: \ Program Files (x86) \ Jenkins \ workspace \ UiUnitTests> echo C: \ Program Files (x86) \ Jenkins \ workspace \ UiUnitTests \ node_modules \ @angular \ cli \ bin; C: \ Windows \ system32; C: \ Windows; C: \ Windows \ System32 \ Wbem; C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \; C: \ Program Files \ Amazon \ cfn-bootstrap \; C: \ Ruby23- x64 \ bin; C: \ Program Files \ nodejs \; C: \ Windows \ system32 \ config \ systemprofile \ AppData \ Local \ Microsoft \ WindowsApps C: \ Program Files (x86) \ Jenkins \ workspace \ UiUnitTests \ node_modules \ @angular \ cli \ bin; C: \ Windows \ system32; C: \ Windows; C: \ Windows \ System32 \ Wbem; C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \; C: \ Program Files \ Amazon \ cfn-bootstrap \; C: \ Ruby23-x64 \ bin; C: \ Program Files \ nodejs \; C: \ Windows \ system32 \ Config \ systemprofile \ AppData \ Local \ Microsoft \ WindowsApps

+7
windows path batch-file jenkins angular-cli
source share
1 answer

Do not install the CLI globally.

Run npm install for the repo and anytime you need to run the ng command, use this:

 node_modules/.bin/ng [command goes here] 

This will save installation time and ensure that there are no differences between your local and global versions.

Additional comment: update the application to the latest version of the CLI

+14
source share

All Articles