Jenkins: Project using Node

  1. Setup SSH Server
    in Manage Jenkins > Configure System


    Checked Use password authentication, or use a different key
    then type password or key.
  2. Create FreeStyle project.
  3. In Source Code Management
    select Git and insert Repository URL, Credential.

  4. Build steps.
    1. Add Execute shell and put below command
    npm install
    npm run build

    2. Add Send files or execute commands over SSH
    Create 2 sets of Transfers.

    Step 1: remove all existing files.
    Remote directory
    <project_name>

    Exec command:
    rm -rf /var/www/html/<project_name>/*


    Step 2: Transfer new files.
    Source files:
    dist/**
    Remove prefix:
    dist
    Remote directory:
    <project_name>
    Exec command:
    chmod -R 777 /var/www/html/<project_name>/*


  5. Apply and Build.