We have a jenkins CI/CD pipeline(using Jenkinsfile) which deploys into K8S from various git branches(dev,master etc).
I am now looking to Roll Back to Previous Version of deployment in Jenkins CI/CD.
I went through few stack overflow questions but nothing worked. Could you help please.
It depends on what you want to achieve.
When using CI/CD, you typically do your changes in a Git repository, and then the changes are validated and rolled out.
A rollback in such workflow, is a revert in the Git repository. The validation and roll out is working the same way.
You may also do things like Canary Deployment with programmed rollbacks, but how you do that depends on how you implement it.
This is easy . Find the image tag in your repository that corresponds to the commit of your latest stable branch and deploy that. You can also edit the deployment live in kubernetes and just change the tag of the image.