Is there a way to find the id of the commit used in an automated git deployment to an Azure website?
Particularly, after that deployment has been swapped in to another deployment slot (which is NOT configured for auto-git deployment).
EDIT: Preferably a programmatic way, but visible in either portal would be a good start.
sending a request to
https://<yourSiteName>.scm.azurewebsites.net/api/deployments
should get you an array of objects that look like this
{
"id":"3a706bb8f1e39b1f01f1911c1440d31077c90e8e",
"status":4,
"status_text":"",
"author_email":"[email protected]",
"author":"FistName LastName",
"deployer":"userName",
"message":"Site updated: 2015-02-12 00:00:00",
"progress":"",
"received_time":"2015-02-12T00:00:00Z",
"start_time":"2015-02-12T00:00:00Z",
"end_time":"2015-02-12T00:00:00Z",
"last_success_end_time":"2015-02-12T00:00:00Z",
"complete":true,
"active":true,
"is_temp":false,
"is_readonly":false,
"url":"https://<yourSiteName>.scm.azurewebsites.net/api/deployments/3a706bb8f1e39b1f01f1911c1440d31077c90e8e",
"log_url":"https://<yourSiteName>.scm.azurewebsites.net/api/deployments/3a706bb8f1e39b1f01f1911c1440d31077c90e8e/log",
"site_name":"yourSiteName"
}
with "id" being the commit id that was used for a deployment.
If you didn't want to call the API, you could do this with a Post Deployment Action Hook.
running a commit like this will get you the hash:
git log -1 | sed -n '/commit/p'
You will need to figure out how you'd want to store it in order to access it. Options include environment variable or text file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With