Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure website and Git commit id

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.

like image 996
David Russell Avatar asked Oct 27 '25 06:10

David Russell


2 Answers

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.

like image 179
ahmelsayed Avatar answered Oct 29 '25 20:10

ahmelsayed


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.

like image 38
cory-fowler Avatar answered Oct 29 '25 20:10

cory-fowler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!