Build a Node.js and React app with npm within Jenkins Pipeline¶
Fork the sample repository on GitHub
Jenkins Setup (Linux Machine)
Create a bridge network in Docker
docker network create jenkins
Create the following volumes
docker volume create jenkins-docker-certs
docker volume create jenkins-data
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
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
Open up following URL in browser localhost:8080 Setup wizard
Creating the first administrator user
Instance Configuration
Start using Jenkins
Create new jobs
Enter an item name field, specify the name for your new Pipeline project
Add pipeline description and choose Pipeline script from SCM option.
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
The Blue Ocean interface turns green if Jenkins built your Node.js and React application successfully.
Added test stage to Pipeline
Added a final deliver stage to Pipeline
React app running on localhost:3000
Onclick the Proceed button to complete the Pipeline’s execution.