Iteration is not a unique value, so there is no simple answer.
It depends how you determine which Iteration are you on and it may be different from one project to another, from one team to another.
You may query the Iterations REST API using the current date as pivot, but I will not recommend this. What if you run the build on an older version of code? It will pick the iteration from today, not from the code timestamp.
The best approach is to the source code version, you have the handy Build.SourceVersion
variable, and a good build report linking all information together (look at at GenerateReleaseNotes Task for example).