before installing Jenkins I ran this: npm install -g @angular/cli
but I also have this in devDependencies in the package.json for the project:
"@angular/cli": "1.0.0-beta.32.3",
when running a Jenkins build, I get this message in the log:
'ng' is not recognized as an internal or external command, operable program or batch file.
=======================================
Here is the Windows batch command in Jenkins:
cmd /c call npm install
set Path=%WORKSPACE%\node_modules\@angular\cli\bin;%PATH%
echo %PATH%
ng build -prod
========================================
here is a little 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, operable program or batch file.
C:\Program Files (x86)\Jenkins\workspace\UiUnitTests>exit 9009 Build step 'Execute Windows batch command' marked build as failure
but when I run this just from the command line (not in a Jenkins job), this works fine:
C:\Program Files (x86)\Jenkins\workspace\UiUnitTests>ng build -prod
To disable this warning use "ng set --global warnings.versionMismatch=false". Hash: 7853ecb5a81a25eadbeb Time: 61317ms chunk {0} polyfills.7aaf5284cd5921eea40b.bundle.js (polyfills) 278 kB {4} [initial] [rendered] chunk {1} main.3380f71d3e71966aea27.bundle.js (main) 371 kB {3} [initial] [rendered] chunk {2} styles.9db1bafdfc989b37db97.bundle.css (styles) 69 bytes {4} [initial] [rendered] chunk {3} vendor.24574fc8320129058fac.bundle.js (vendor) 2.18 MB [initial] [rendered] chunk {4} inline.d1f5b52100bed2568d44.bundle.js (inline) 0 bytes [entry] [rendered]
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
In Jenkins, go to the project configuration of the project for which you want to run an automated build. In the 'Build Triggers' section, select 'Build when a change is pushed to GitHub'. Save your project.
Run the command java -jar jenkins. war . Browse to http://localhost:8080 and wait until the Unlock Jenkins page appears.
Do not install the CLI globally.
Run the npm install
for the repo and any time you need to run an ng
command use this:
node_modules/.bin/ng [command goes here]
This will save on install time and ensure there are no differences between your local and global versions.
Additional commentary: Update your app to the latest version of the CLI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With