I configured Jenkins on the EC2 instance yesterday. Jenkins was successfully sending post build notifications with the build URL (EC2_PublicDNS/job/build_name/build_number) in my inbox. I restarted my EC2 instance on AWS today and the public DNS changes when we restart the instance. Currently, Jenkins is sending me email notifications with the build URL of the previous public DNS. How can I fix Jenkins to send the build URL with current public DNS of EC2 instance?
post {
success {
mail to: 'abc@test.com',
subject: "Success: ${currentBuild.fullDisplayName}",
body: "Pipeline is executed successfully for build ${env.BUILD_URL}"
}
}