Build a Node.js and React app with npm within Jenkins Pipeline

  1. Fork the sample repository on GitHub

forked simple-node-js-react-npm-app repository (on GitHub)

Jenkins Setup (Linux Machine)

  1. Create a bridge network in Docker

docker network create jenkins
  1. Create the following volumes

docker volume create jenkins-docker-certs
docker volume create jenkins-data
  1. In order to execute Docker commands inside Jenkins nodes, download and run the docker:dind Docker image

docker container run --name jenkins-docker --rm --detach \
--privileged --network jenkins --network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
--volume "$HOME":/home \
--publish 3000:3000 docker:dind
  1. Run the jenkinsci/blueocean image as a container in Docker using the following docker container run command

docker container run --name jenkins-tutorial --rm --detach \
--network jenkins --env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
--volume "$HOME":/home --publish 8080:8080 jenkinsci/blueocean
  1. Open up following URL in browser localhost:8080 Setup wizard

Unlocking Jenkins
  1. Creating the first administrator user

../../_images/02.png
  1. Instance Configuration

../../_images/03.png
  1. Start using Jenkins

../../_images/04.png
  1. Create new jobs

../../_images/05.png
  1. Enter an item name field, specify the name for your new Pipeline project

../../_images/06.png
  1. Add pipeline description and choose Pipeline script from SCM option.

../../_images/07-1.png
  1. Open Blue Ocean | click Run, then quickly click the OPEN link which appears briefly at the lower-right to see Jenkins building your Pipeline project

../../_images/08.png
  1. The Blue Ocean interface turns green if Jenkins built your Node.js and React application successfully.

../../_images/10.png
  1. Added test stage to Pipeline

../../_images/11.png
  1. Added a final deliver stage to Pipeline

../../_images/12.png
  1. React app running on localhost:3000

../../_images/13.png
  1. Onclick the Proceed button to complete the Pipeline’s execution.

../../_images/14.png