how to automize build and deploy phases of unity android/ios outputs using ci/cd (like jenkins)?

I know there are plugins for google play deploy and unity3d build to run build scripts in unity. but for complete control over build and deploy process, I need more controls. for example, I need to export to the android studio project to resolve conflicts and some of the dependencies or for ios output, we have to make xcode and change the project to xworkspace and… change some files to be able to build. i think all of these can be achieved by cmd or Mac Terminal but how can I call them in jenkins and how can I set events like successful android studio build or successful unity build?