In the previous post Gitlab-CI-Spring-Boot-Heroku-Continuous-integration-and-Deployment/, Every commit to master branch , Gitlab CI will build and deploy the application to two different environments (dev and stage). This is great. How about creating a new dynamic environment for every new merge request (branch) ? . The Repository owner can review the merge request and provide you the immediate feedback. Yes ! That is called “Review Apps” Review Apps
- Developers create a new branch “feature-xyz” and start implementing the features which he is supposed to complete as part of the Agile development process.
- Developers commits the code, test it locally before pushing the branch to remote repository.
- As soon as the branch (feature-xyz) is pushed to repository, Gitlab CI will trigger the pipeline ,which will deploy the feature branches into a new dynamic environment.
When a merge request is created , the corresponding dynamic environment is shown in the page as shown above.
As I have four feature branches in my repository , four environments get deployed by Gitlab CI. Each dynamic environment will be deleted once the corresponding branch is deleted. It can also be stopped manually from the Gitlab UI.
The complete gitlab-ci.yml is shown below.
Review : Responsible for creating a new environment for every new branch
Stop_Review : Responsible for deleting the environment whenever the branch is deleted or manually stopped from Gitlab UI.