We generally come across terms like continuous integration, continuous delivery and continuous deployment while following Software model like Agile methodology. Mostly, these terms are confusing and they are inter-related. Let's find out the difference between them and try to understand what these actually mean in software development and how these can work together to give us a process that everyone including managers, developers and customers would like to follow.
Continuous Integration is continuously/constantly merging your code or development work into Master or Main branch so that while you work on other things, your committed/merged code can be tested. The basic logic behind this is to test your code as early as it is being committed and find or catch the bugs early so that you can fix them before the changes go to production. Most of the work is automated using build server which performs these tests and developers can work on their task simultaneously.
Continuous delivery is a process of delivering the code continuously to an environment when developer feels the code can be shipped. This environment could be staging, QA, or production. The basic idea behind this is to review or inspect the shipped code, so that one can find and fix any issues at an earlier stage. This is similar to Continuous Integration, but here we can test business logic. Here, you can also do code review for delivered code and get the feedback and based on the feedback, code correction can be done. In this process, the delivered code is shipped along with required configuration and settings, so you make sure that the delivered code is running in the same environment. The basis of continuous delivery is small batches of work shipped to the next level in order to identify any bug/issue in the delivered code.
Continuous Deployment is the process of deployment or release of code to Production as soon as it is ready. All the testing which is performed prior to merging to main branch is done on Production like environment with all the configuration settings similar to Production environment to avoid any further issues. This deployment to Production is done using an automated process. This automated process can be performed by anyone in few minutes, for example, within few clicks. Continuous Deployment process requires Continuous Integration and Continuous Delivery, else you may get some errors in Production environment. In this complete process, you should automate your Continuous Integration with build server and Continuous Delivery to staging, and should automate the deployment process to production.
So Continuous Integration, Continuous Delivery and Continuous Deployment work together to ship code to Production environment with minimal bugs, this means it takes care of quality of your product. Developer checks in code to development branch, build server picks up the change, it performs Unit Tests. If Unit Tests passed successfully, then it merges the code to Staging Environment. If successful deployment to staging is finished, then QA tests the environment and if this passed, then it moves to production. This process may vary based on needs, requirements of project.
Continuous Deployment mainly relies on small changes which are continuously tested and are deployed and released to production after it is tested in previous environments.