Details
-
Type:
Task
-
Status: Done (View Workflow)
-
Priority:
Minor
-
Resolution: Fixed
-
Component/s: content
-
Similar Issues:
Description
Tutorial outline/plan:
Note: I'd recommend reviewing the WEBSITE-412 tutorial first before proceeding because it's like a prequel to this one.
Readers effectively start off with a Jenkinsfile Pipeline that has both a "Build" and "Test" stage in it. This is effectively the same as the Jenkinsfile that readers create in WEBSITE-412 tutorial (but only up to and including the "Test" stage). From that point on, things change dramatically.
The tutorial process (at a high-level) will be:
- The reader forks the "building-a-multibranch-pipeline-project" GitHub project and clones it locally (fairly standard so far).
This project is effectively the same as the "simple-node-js-react-npm-app" used inWEBSITE-412, but with different 'deliver-for-development.sh' and 'deploy-for-production.sh' scripts which are run selectively depending on the branch that Jenkins executes. - Reader creates (locally) 2 branches from the single "master" branch in this repo - "production" and "development".
Note: I decided not to use the "master" branch for "production" purposes because I don't think this is that common/recommended in practice. For example, a "production" branch might be in use for some time while unstable development continues along the "master" branch. (Please feel free to correct me if I'm wrong and we can alter this step to suit.) - Reader configures their multibranch Pipeline project in the Blue Ocean UI using the Git option. The presence of a 'bare' Jenkinsfile in the original "master" branch is to populate the Blue Ocean UI with each branch in the repo (making them accessible without having to leave the Blue Ocean UI).
- Reader updates the existing 'bare' Jenkinsfile with the initial "Build" and "Test" stages for the project in the "master" branch.
- Reader switches to Blue Ocean in Jenkins and builds the "master" branch to see the end result - i.e. the "Build" and "Test" stages are executed.
- Reader adds the "Deliver for development" and "Deploy for production" stages to their Jenkinsfile (in the "master" branch), runs a build in Jenkins again and sees that these two stages are bypassed - i.e. none of these newly added stages actually execute (because both these stages have "when" conditions that aren't yet satisfied).
- Reader switches to Blue Ocean in Jenkins again and builds the "develop" and "production" branches to see the end result - i.e. the "Deliver for development" (because its "when { branch 'development' }" condition is satisfied) and "Deploy for production" (because its "when { branch 'production' }" condition is satisfied) stages are selectively executed.
- The "Deliver for development" stage is effectively the npm start (and associated) commands in the deliver.sh script (of "simple-node-js-react-npm-app" for
WEBSITE-412). - This "Deploy for production" stage is effectively the npm install -g serve followed by serve -c 0 -s build in the deploy-for-production.sh script of "building-a-multibranch-pipeline-project".
- The "Deliver for development" stage is effectively the npm start (and associated) commands in the deliver.sh script (of "simple-node-js-react-npm-app" for
As an optional 'Follow up' section:
- Reader checks out the "development" branch, makes some changes to the src/App.js file and commits it to the "development" branch.
- Reader switches to Blue Ocean in Jenkins again and builds the "development" branch to see the end result of the "Deliver for development" build.
- Reader pulls changes from their "development" branch to their "production" branch (via "master") and back in Blue Ocean again, builds the "production" branch to see the end result of the "Deploy for production" build.
- Mention how reader can submit a PR to master (as a sum up line).
Will effectively be 'done' when PR 1237 is merged.