File tree Expand file tree Collapse file tree 4 files changed +88
-0
lines changed Expand file tree Collapse file tree 4 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ pipeline {
2+ agent {
3+ docker {
4+ image ' node:6-alpine'
5+ args ' -p 3000:3000'
6+ }
7+ }
8+ environment {
9+ CI = ' true'
10+ }
11+ stages {
12+ stage(' Build' ) {
13+ steps {
14+ sh ' npm install'
15+ }
16+ }
17+ stage(' Test' ) {
18+ steps {
19+ sh ' ./jenkins/scripts/test.sh'
20+ }
21+ }
22+ stage(' Deliver' ) {
23+ steps {
24+ sh ' ./jenkins/scripts/deliver.sh'
25+ input message : ' Finished using the web site? (Click "Proceed" to continue)'
26+ sh ' ./jenkins/scripts/kill.sh'
27+ }
28+ }
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env sh
2+
3+ echo ' The following "npm" command builds your Node.js/React application for'
4+ echo ' production in the local "build" directory (i.e. within the'
5+ echo ' "/var/jenkins_home/workspace/simple-node-js-react-app" directory),'
6+ echo ' correctly bundles React in production mode and optimizes the build for'
7+ echo ' the best performance.'
8+ set -x
9+ npm run build
10+ set +x
11+
12+ echo ' The following "npm" command runs your Node.js/React application in'
13+ echo ' development mode and makes the application available for web browsing.'
14+ echo ' The "npm start" command has a trailing ampersand so that the command runs'
15+ echo ' as a background process (i.e. asynchronously). Otherwise, this command'
16+ echo ' can pause running builds of CI/CD applications indefinitely. "npm start"'
17+ echo ' is followed by another command that retrieves the process ID (PID) value'
18+ echo ' of the previously run process (i.e. "npm start") and writes this value to'
19+ echo ' the file ".pidfile".'
20+ set -x
21+ npm start &
22+ sleep 1
23+ echo $! > .pidfile
24+ set +x
25+
26+ echo ' Now...'
27+ echo ' Visit http://localhost:3000 to see your Node.js/React application in action.'
28+ echo ' (This is why you specified the "args ' ' -p 3000:3000' ' " parameter when you'
29+ echo ' created your initial Pipeline as a Jenkinsfile.)'
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env sh
2+
3+ echo ' The following command terminates the "npm start" process using its PID'
4+ echo ' (written to ".pidfile"), all of which were conducted when "deliver.sh"'
5+ echo ' was executed.'
6+ set -x
7+ kill $( cat .pidfile)
8+ set +x
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env sh
2+
3+ echo ' The following "npm" command (if executed) installs the "cross-env"'
4+ echo ' dependency into the local "node_modules" directory, which will ultimately'
5+ echo ' be stored in the Jenkins home directory. As described in'
6+ echo ' https://docs.npmjs.com/cli/install, the "--save-dev" flag causes the'
7+ echo ' "cross-env" dependency to be installed as "devDependencies". For the'
8+ echo ' purposes of this tutorial, this is not important. However, this is'
9+ echo ' typically how this dependency would be installed. For a comprehensive'
10+ echo ' exaplanation about "devDependencies", see'
11+ echo ' https://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies.'
12+ set -x
13+ # npm install --save-dev cross-env
14+ set +x
15+
16+ echo ' The following "npm" command tests that your simple Node.js/React'
17+ echo ' application renders satisfactorily. This command actually invokes the test'
18+ echo ' runner Jest (https://facebook.github.io/jest/).'
19+ set -x
20+ npm test
21+ set +x
You can’t perform that action at this time.
0 commit comments