Each environment will have its own pipeline on the CAW’s Jenkins server. The project name on Jenkins will be the same as the app name. Inside the Jenkins project, you will create one pipeline per environment (or branch) with the name <app name>-<environment name>

There will be only one common Jenkins build script for the pipelines of all the environments. The branch name and other config parameters like the deployment bucket name, AWS keys etc.. will be configured in Jenkins server as config keys (plain and secret) and sent as variables to the script.

The Jenkins build script will be committed as part of the codebase in a folder called build-scripts

<aside> ⛔ Never commit any keys or buckets names in the Jenkins file in the source control

</aside>

The Jenkins script will, at a high level, perform the following steps

  1. Pull the latest code from the branch. The branch name will be in the config params. Each pipeline will send the branch name to build as input
  2. Read the version number from the env file. Set the build number (the BUILD_NUMBER part in X.Y.Z_BUILD_NUMBER) to the current Pipeline Build Number and update the version in env file. Set the same version in package.json file as well (variable is called version).
  3. Build the application based on the env name. Ensure you generate source maps
  4. Using Sentry CLI, set the release number to the version number that you computed in step 2 and upload the source maps file (Read:https://docs.sentry.io/platforms/javascript/sourcemaps/)
  5. Delete the source map files ⚠️
  6. Generate manifest file and add to assets folder (more about manifest file here)
  7. Deploy the build to cloud (AWS bucket or Azure Blob storage)
  8. Bust the cache entry of Index.html from the CDN (AWS CloudFront or Azure CDN Cache)

Manifest File Generation Step for Jenkins

In each Jenkins pipeline, we will have a build parameter called "forceUpdate". The default value of this variable is false.

Create a new file called manifest.json and add it to the assets folder. The manifest.json will have the following structure

{

version: <the version number from package.json>

forceUpdate: <the value of the build parameters>