How do I access the current Heroku release version programmatically?

后端 未结 5 1601
一整个雨季
一整个雨季 2021-02-18 19:22

Is this even possible - is there something like a RELEASE_VERSION environment variable?

5条回答
  •  说谎
    说谎 (楼主)
    2021-02-18 19:56

    The above approach mentioned by Tomaž Zaman will do the job if you have less that 200 releases for your app. Otherwise will not... please refer to Ranges section from Heroku API Documentation:

    https://devcenter.heroku.com/articles/platform-api-reference#ranges

    You don't need Heroku Labs feature Metadata. This is what you need:

    curl --request GET \
      --url https://api.heroku.com/apps/{APP_NAME_ID}/releases \
      --header 'Accept: application/vnd.heroku+json; version=3' \
      --header 'Authorization: Bearer {AUTH_TOKEN}' \
      --header 'Range: version;order=desc,max=1'
    

    This will retrieve a list with latest releases (in this case only one, max=1) and what you need to do is to get response[0], that's it.

提交回复
热议问题