Jenkins - Angular : how to execute ng build after git push

Please follow below steps to setup npm install and auto build via Jenkins.

  1. Login to your jenkins account
  2. Click on New Item from left menu and Select Freestyle project and set project name as per your requirement.
  3. After That on Configure screen set your git repository project link.
  4. Then next option is custom repository and set your custom server path into that.
  5. In Source Code Management click on Git and set Project link and credentials.
  6. Set which branch would you like to use for build.
  7. If want to run this configuration on daily basis then check Poll SCM and set time.
  8. Then go to Build Management and select Execute Shell option and setup below commands in proper way.
  • npm install
  • ng build --no-aot --no-build-optimizer --base-href ./
  • cp -R CUSTOM PATH(path to your custom repository where build is stored/dist/*) SOURCE PATH(path to your source repository where project is run) (Here you have to set your project path)

Please find below screen shot for better understanding

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here